This PR adds support for optionally running pyodide in a web worker:
- add a new option config.execution_thread, which can be `main` or `worker`. The default is `main`
- improve the test machinery so that we run all tests twice, once for `main` and once for `worker`
- add a new esbuild target which builds the code for the worker
The support for workers is not complete and many features are still missing: there are 71 tests which are marked as `@skip_worker`, but we can fix them in subsequent PRs.
The vast majority of tests fail because js.document is unavailable: for it to run transparently, we need the "auto-syncify" feature of synclink.
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Madhur Tandon <20173739+madhur-tandon@users.noreply.github.com>
In the future this should help us leak fewer names into the pyscript
namespace.
Rather than assigning to the pyscript module from JavaScript, we
mount a separate private JS module with the extra names needed by
PyScript. I moved a bit more interpeter intialization into
remote_interpreter.
I added a deprecation warning for `pyscript.js`: the proper way to
access `js` is `import js`.
---------
Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
* kill the PyScript class and the weird pyscript instance; from the user point of view its functionalities are still available as pyscript.*, but pyscript is not the module, not the instance of PyScript
* simplify the code in _set_version_info, while I'm at it
* start to implement DeprecatedGlobal
* DeprecatedGlobal.__getattr__
* don't show the same warning twice
* DeprecatedGlobal.__call__
* make it possible to specify a different warning message for every global
* WIP: carefully use DeprecatedGlobal to show reasonable warning messages depending on which name you are accessing to. More names to follow
* deprecate more names
* deprecate private names
* depreacte direct usage of console and document
* deprecate the PyScript class
* use a better error message
* fix test_pyscript.py
* introduce a __repr__ for DeprecatedGlobal
* add an helper to ensure that we don't show any error or warning on the page
* WIP: ensure that examples don't use depreacted features. Many tests are failing
* don't deprecate Element
* don't use the global micropip to install packages, else we trigger a warning
* use a better error message for micropip
* fix test_todo_pylist to avoid using deprecated globals
* fix test_webgl_raycaster
* fix tests
* make HTML globally available
* add MIME_RENDERERS and MIME_METHODS
* fix the typing of Micropip, thanks to @FabioRosado
* Import current version as PyScript.__version__ and PyScript.version_info
* Add integration, python unit tests
* Mock pyscript.py with __mocks__/pyscript.js to make jest tests happy
* Revert to runPython instead of await runPythonAsync
* "Implicit Coroutines" are no longer permitted in py-script tags
* Tests added for the above
* xfail test_importmap (See #938)
- display(some_str) escapes the string by default. This is almost always what you want
- display(some_obj) calls repr(obj) and escapes the result. Again, it's a very sensible default
- if you want to inject some raw HTML in the output, you can use the new HTML class: display(HTML("<p>hello</p>")).
* add build to the make examples cmd so that it automates more to the user
* temporarily improve error managament when executing eval until we properly refactor the whole io and error workflow
* add minimal test for format_mime
* move current integration tests to the integration folder
* move pyscript.py into its own python folder
* change the path for python unit testing files
* change pyscript.py path
* Update Makefile
* remove echo
* replace conda run with pytest directly
* oops, add python test files I embarrassingly forgot to add
Co-authored-by: Peter W <34256109+pww217@users.noreply.github.com>