Skip to content

Commit e9195bc

Browse files
Merge pull request #227 from Distributive-Network/caleb/fix/this
Caleb/fix/this
2 parents 9a3a36a + 00dfec4 commit e9195bc

File tree

109 files changed

+2989
-1433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2989
-1433
lines changed

.github/workflows/test-and-publish.yaml

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ on:
88
- '*'
99
workflow_call:
1010
workflow_dispatch:
11+
inputs:
12+
debug_enabled:
13+
type: boolean
14+
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
15+
required: false
16+
default: false
17+
dump_cores:
18+
type: boolean
19+
description: 'Include core dumps in CI artifacts'
20+
required: false
21+
default: false
1122
pull_request:
1223

1324
env:
@@ -31,17 +42,17 @@ jobs:
3142
python_version: [ '3.10' ]
3243
runs-on: ${{ matrix.os }}
3344
steps:
34-
- uses: actions/checkout@v3
35-
- uses: actions/setup-python@v4
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-python@v5
3647
with:
3748
python-version: ${{ matrix.python_version }}
3849
- name: Cache spidermonkey build
3950
id: cache-spidermonkey
40-
uses: actions/cache@v3
51+
uses: actions/cache@v4
4152
with:
4253
path: |
4354
./_spidermonkey_install/*
44-
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
55+
key: spidermonkey115.8.0-${{ runner.os }}-${{ runner.arch }}
4556
lookup-only: true # skip download
4657
- name: Setup XCode
4758
if: ${{ (matrix.os == 'macos-13' || matrix.os == 'macos-14') && steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
@@ -54,14 +65,14 @@ jobs:
5465
build-spidermonkey-win:
5566
runs-on: windows-2019
5667
steps:
57-
- uses: actions/checkout@v3
68+
- uses: actions/checkout@v4
5869
- name: Cache spidermonkey build
5970
id: cache-spidermonkey
60-
uses: actions/cache@v3
71+
uses: actions/cache@v4
6172
with:
6273
path: |
6374
./_spidermonkey_install/*
64-
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
75+
key: spidermonkey115.8.0-${{ runner.os }}-${{ runner.arch }}
6576
lookup-only: true # skip download
6677
- name: Install dependencies
6778
if: ${{ steps.cache-spidermonkey.outputs.cache-hit != 'true' }}
@@ -104,12 +115,12 @@ jobs:
104115
python_version: '3.9'
105116
runs-on: ${{ matrix.os }}
106117
steps:
107-
- uses: actions/checkout@v3
118+
- uses: actions/checkout@v4
108119
with:
109120
submodules: recursive
110121
fetch-depth: 0 # fetch all history for all branches and tags
111122
# poetry-dynamic-versioning needs git tags to produce the correct version number
112-
- uses: actions/setup-python@v4
123+
- uses: actions/setup-python@v5
113124
with:
114125
python-version: ${{ matrix.python_version }}
115126
- name: Setup Poetry
@@ -138,11 +149,11 @@ jobs:
138149
poetry install --no-root --only=dev
139150
echo "Installed Dependencies"
140151
- name: Use cached spidermonkey build
141-
uses: actions/cache@v3
152+
uses: actions/cache@v4
142153
with:
143154
path: |
144155
./_spidermonkey_install/*
145-
key: spidermonkey115.7.0-${{ runner.os }}-${{ runner.arch }}
156+
key: spidermonkey115.8.0-${{ runner.os }}-${{ runner.arch }}
146157
fail-on-cache-miss: true # SpiderMonkey is expected to be cached in its dedicated job
147158
- name: Build pminit
148159
run: |
@@ -167,20 +178,55 @@ jobs:
167178
with:
168179
name: docs-${{ github.run_id }}-${{ github.sha }}
169180
path: ./build/docs/html/
181+
- name: Set cores to get stored in /cores
182+
if: ${{ matrix.os != 'windows-2019' && github.event_name == 'workflow_dispatch' && inputs.dump_cores }}
183+
# TODO (Caleb Aikens) figure out how to get Windows core dumps
184+
run: |
185+
sudo mkdir -p /cores
186+
sudo chmod 777 /cores
187+
# Core filenames will be of the form osname.pythonversion.executable.pid.timestamp:
188+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
189+
sudo bash -c 'echo "/cores/${OSTYPE}.$(poetry run python --version).%e.%p.%t" > /proc/sys/kernel/core_pattern'
190+
else
191+
sudo sysctl kern.corefile="/cores/${OSTYPE}.$(poetry run python --version).%e.%p.%y"
192+
fi
170193
- name: Run Python tests (pytest)
171194
run: |
195+
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
196+
# TODO (Caleb Aikens) figure out how to get Windows core dumps
197+
ulimit -c unlimited
198+
fi
172199
poetry run python -m pip install --force-reinstall --verbose ./dist/*
173200
poetry run python -m pytest tests/python
174201
- name: Run JS tests (peter-jr)
202+
if: ${{ (success() || failure()) }}
175203
run: |
204+
if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "darwin"* ]]; then
205+
# TODO (Caleb Aikens) figure out how to get Windows core dumps
206+
ulimit -c unlimited
207+
fi
176208
poetry run bash ./peter-jr ./tests/js/
209+
- name: Upload core dumps as CI artifacts
210+
uses: actions/upload-artifact@v3
211+
if: ${{ matrix.os != 'windows-2019' && github.event_name == 'workflow_dispatch' && inputs.dump_cores }}
212+
# TODO (Caleb Aikens) figure out how to get Windows core dumps
213+
with:
214+
name: cores-${{ matrix.os }}-${{ matrix.python_version }}
215+
path: /cores
216+
# Enable tmate debugging of manually-triggered workflows if the input option was provided
217+
- name: SSH debug session
218+
if: ${{ (success() || failure()) && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
219+
uses: mxschmitt/action-tmate@v3
220+
with:
221+
detached: true
222+
limit-access-to-actor: true
177223
sdist:
178224
runs-on: ubuntu-20.04
179225
steps:
180-
- uses: actions/checkout@v3
226+
- uses: actions/checkout@v4
181227
with:
182228
fetch-depth: 0
183-
- uses: actions/setup-python@v4
229+
- uses: actions/setup-python@v5
184230
with:
185231
python-version: '3.9'
186232
- name: Setup Poetry
@@ -203,7 +249,7 @@ jobs:
203249
if: ${{ success() && github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
204250
steps:
205251
# no need to checkout
206-
- uses: actions/setup-python@v4
252+
- uses: actions/setup-python@v5
207253
with:
208254
python-version: '3.9'
209255
- run: pip install twine

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
6161
set(Python_FIND_VIRTUALENV FIRST) # (require cmake >= v3.15 and this is the default) use the Python version configured by pyenv if available
6262
set(PYTHON_LIBRARIES ${Python_LIBRARIES})
6363
set(PYTHON_INCLUDE_DIR ${Python_INCLUDE_DIRS})
64+
message("Linux - Using Python:${Python_VERSION_MAJOR}.${Python_VERSION_MINOR} - Libraries:${PYTHON_LIBRARIES} - IncludeDirs: ${PYTHON_INCLUDE_DIR}")
6465
find_package(SpiderMonkey REQUIRED)
6566
elseif(WIN32)
6667
find_package(PythonInterp 3.8 REQUIRED)

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ using the Python engine to provide the Javascript host environment.
88

99
We feature JavaScript Array and Object methods implemented on Python List and Dictionaries using the cPython C API, and the inverse using the Mozilla Firefox Spidermonkey JavaScript C++ API.
1010

11-
This product is in an intermediate stage, approximately 95% to MVP as of March 2024. It is under active development by [Distributive](https://distributive.network/).
11+
This product is in an advanced stage, approximately 95% to MVP as of March 2024. It is under active development by [Distributive](https://distributive.network/).
12+
1213
External contributions and feedback are welcome and encouraged.
1314

1415
### tl;dr
@@ -250,6 +251,7 @@ generated by enumerating the global variable in the current SpiderMonkey context
250251
## Built-In Functions
251252

252253
See definitions in [python/pythonmonkey/global.d.ts](https://github.com/Distributive-Network/PythonMonkey/blob/main/python/pythonmonkey/global.d.ts).
254+
Including:
253255

254256
- `console`
255257
- `atob`
@@ -307,11 +309,11 @@ JavaScript Array and Object methods are implemented on Python List and Dictionar
307309

308310
| JavaScript Type | Python Type |
309311
|:---------------------|:----------------|
310-
| string | String
312+
| string | pythonmonkey.JSStringProxy (String)
311313
| number | Float
312314
| bigint | pythonmonkey.bigint (Integer)
313315
| boolean | Bool
314-
| function | Function
316+
| function | pythonmonkey.JSFunctionProxy || pythonmonkey.JSMethodProxy (Function || Method)
315317
| object - most | pythonmonkey.JSObjectProxy (Dict)
316318
| object - Date | datetime
317319
| object - Array | pythonmonkey.JSArrayProxy (List)
@@ -386,10 +388,10 @@ in Python. Simply decorate a Dict named `exports` inside a file with a `.py` ext
386388
loaded by `require()` -- in either JavaScript or Python.
387389

388390
### Program Module
389-
The program module, or main module, is a special module in CommonJS. In a program module,
391+
The program module, or main module, is a special module in CommonJS. In a program module:
390392
- variables defined in the outermost scope are properties of `globalThis`
391393
- returning from the outermost scope is a syntax error
392-
- the `arguments` variable in an Array-like object which holds your program's argument vector
394+
- the `arguments` variable in an Array which holds your program's argument vector
393395
(command-line arguments)
394396

395397
```console
@@ -416,7 +418,7 @@ exports['today'] = date.today()
416418
# Troubleshooting Tips
417419

418420
## CommonJS (require)
419-
If you are having trouble with the CommonJS require function, set environment variable `DEBUG='ctx-module*'` and you can see the filenames it tries to laod.
421+
If you are having trouble with the CommonJS require function, set environment variable `DEBUG='ctx-module*'` and you can see the filenames it tries to load.
420422

421423
## pmdb
422424

@@ -453,7 +455,7 @@ List of commands:
453455
```console
454456
$ pmjs
455457

456-
Welcome to PythonMonkey v0.2.0.
458+
Welcome to PythonMonkey v0.4.0.
457459
Type ".help" for more information.
458460
> .python import sys
459461
> .python sys.path

build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Main PythonMonkey build automation script. Run with `poetry build`.
33
# @author Hamada Gasmallah, [email protected]
44
# @date April 2023
5+
# @copyright Copyright (c) 2023 Distributive Corp.
56
#
7+
68
import subprocess
79
import os, sys
810
import platform

include/BoolType.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
* @file BoolType.hh
33
* @author Caleb Aikens ([email protected])
44
* @brief Struct for representing python bools
5-
* @version 0.1
65
* @date 2022-12-02
76
*
8-
* @copyright Copyright (c) 2022
7+
* @copyright Copyright (c) 2022 Distributive Corp.
98
*
109
*/
1110

include/BufferType.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @file BufferType.hh
33
* @author Tom Tang ([email protected])
44
* @brief Struct for representing ArrayBuffers
5-
* @version 0.1
65
* @date 2023-04-27
76
*
87
* @copyright Copyright (c) 2023 Distributive Corp.

include/DateType.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
* @file DateType.hh
33
* @author Caleb Aikens ([email protected])
44
* @brief Struct for representing python dates
5-
* @version 0.1
65
* @date 2022-12-21
76
*
8-
* @copyright Copyright (c) 2022
7+
* @copyright Copyright (c) 2022 Distributive Corp.
98
*
109
*/
1110

include/DictType.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
* @file DictType.hh
33
* @author Caleb Aikens ([email protected]) & Giovanni Tedesco ([email protected])
44
* @brief Struct representing python dictionaries
5-
* @version 0.1
65
* @date 2022-08-10
76
*
8-
* @copyright Copyright (c) 2022
7+
* @copyright Copyright (c) 2022 Distributive Corp.
98
*
109
*/
1110

include/ExceptionType.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @file ExceptionType.hh
33
* @author Tom Tang ([email protected]) and Philippe Laporte ([email protected])
44
* @brief Struct for representing Python Exception objects from a corresponding JS Error object
5-
* @version 0.1
65
* @date 2023-04-11
76
*
87
* @copyright Copyright (c) 2023-2024 Distributive Corp.

include/FloatType.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
* @file FloatType.hh
33
* @author Caleb Aikens ([email protected])
44
* @brief Struct for representing python floats
5-
* @version 0.1
65
* @date 2022-12-02
76
*
8-
* @copyright Copyright (c) 2022
7+
* @copyright Copyright (c) 2022 Distributive Corp.
98
*
109
*/
1110

0 commit comments

Comments
 (0)