You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+82-23Lines changed: 82 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@
4
4
5
5
## About
6
6
[PythonMonkey](https://pythonmonkey.io) is a Mozilla [SpiderMonkey](https://firefox-source-docs.mozilla.org/js/index.html) JavaScript engine embedded into the Python Runtime,
7
-
using the Python engine to provide the Javascript host environment.
7
+
using the Python engine to provide the Javascript host environment.
8
8
9
-
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.
9
+
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.
10
10
11
-
This product is in an intermediate stage, approximately 90% to MVP as of January 2024. It is under active development by [Distributive](https://distributive.network/).
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/).
12
12
External contributions and feedback are welcome and encouraged.
- Python host environment supplies basic subsets of NodeJS's fs, path, process, etc, modules; as-needed by dcp-client
58
57
-[done] Python TypedArrays coerce to JS TypeArrays
59
58
-[done] JS TypedArrays coerce to Python TypeArrays
60
59
-[done] Python lists coerce to JS Arrays
61
60
-[done] JS arrays coerce to Python lists
61
+
-[90%] PythonMonkey can run the dcp-client npm package from Distributive.
62
62
63
63
## Build Instructions
64
64
@@ -82,7 +82,7 @@ Read this if you want to build a local version.
82
82
If you are using VSCode, you can just press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>B</kbd> to [run build task](https://code.visualstudio.com/docs/editor/tasks#_custom-tasks) - We have [the `tasks.json` file configured for you](.vscode/tasks.json).
83
83
84
84
## Running tests
85
-
1. Compile the project
85
+
1. Compile the project
86
86
2. Install development dependencies: `poetry install --no-root --only=dev`
87
87
3. From the root directory, run `poetry run pytest ./tests/python`
88
88
4. From the root directory, run `poetry run bash ./peter-jr ./tests/js/`
@@ -131,7 +131,7 @@ and install them by `pip install ./dist/*`.
131
131
## Debugging Steps
132
132
133
133
1. [build the project locally](#build-instructions)
134
-
2. To use gdb, run `poetry run gdb python`.
134
+
2. To use gdb, run `poetry run gdb python`.
135
135
See [Python Wiki: DebuggingWithGdb](https://wiki.python.org/moin/DebuggingWithGdb)
136
136
137
137
If you are using VSCode, it's more convenient to debug in [VSCode's built-in debugger](https://code.visualstudio.com/docs/editor/debugging). Simply press <kbd>F5</kbd> on an open Python filein the editor to start debugging - We have [the `launch.json`file configured for you](https://github.com/Distributive-Network/PythonMonkey/blob/main/.vscode/launch.json).
@@ -142,18 +142,43 @@ If you are using VSCode, it's more convenient to debug in [VSCode's built-in deb
These methods are exported from the pythonmonkey module.
147
-
148
-
*eval(code, evalOpts)
149
-
* isCompilableUnit(code)
150
-
* collect()
151
-
* bigint(int)
152
-
*`SpiderMonkeyError`
153
-
*`JSObjectProxy`
154
-
*`null`
155
-
156
-
See definitions in [python/pythonmonkey/pythonmonkey.pyi](https://github.com/Distributive-Network/PythonMonkey/blob/main/python/pythonmonkey/pythonmonkey.pyi).
145
+
## Official API
146
+
These methods are exported from the pythonmonkey module. See definitions in [python/pythonmonkey/pythonmonkey.pyi](https://github.com/Distributive-Network/PythonMonkey/blob/main/python/pythonmonkey/pythonmonkey.pyi).
147
+
148
+
### eval(code, options)
149
+
Evaluate JavaScript code. The semantics of this eval are very similar to the eval used in JavaScript;
150
+
the last expression evaluated in the `code` string is used as the return value of this function. To
151
+
evaluate `code`in strict mode, the first expression should be the string `"use strict"`.
152
+
153
+
#### options
154
+
The eval function supports an options object that can affect how JS code is evaluated in powerful ways.
155
+
They are largely based on SpiderMonkey's `CompileOptions`. The supported option keys are:
156
+
-`filename`: set the filename of this code for the purposes of generating stack traces etc.
157
+
-`lineno`: set the line number offset of this code for the purposes of generating stack traces etc.
158
+
-`column`: set the column number offset of this code for the purposes of generating stack traces etc.
159
+
-`mutedErrors`: experimental
160
+
-`noScriptRval`: experimental
161
+
-`selfHosting`: experimental
162
+
-`strict`: experimental
163
+
-`module`: experimental
164
+
-`fromPythonFrame`: generate the equivalent of filename, lineno, and column based on the location of
165
+
the Python call to eval. This makes it possible to evaluate Python multiline string literals and
166
+
generate stack traces inJS pointing to the error in the Python source file.
167
+
168
+
#### tricks
169
+
- function literals evaluate as`undefined`in JavaScript; if you want to return a function, you must
0 commit comments