Instead of calling `loadWebAssemblyModule` and saving it to
`preloadedWasm`, directly call `loadDynamicLibrary` with proper
`fs` args to locate other shared libs that are dependent.
This uses sed to insert /* webpackIgnore: true */ comments into pyodide.js.
This resolves#3087. I also enabled a check that a simple webpack config
builds without warnings. In the future it would be good to add a test that it
also runs without error.
This adds the distributed binary files to the "exports" section of the package.json file.
This allows the files to be referenced, e.g. by `require.resolve('pyodide/distutils.tar')`
which is useful for tools like webpack.
This updates scipy to v1.9.1. This was mercifully easy:
* for now we disable meson
* we dropped `patches/0014-BUG-Fix-signature-of-D_IIR_forback-1-2.patch` since it was upstreamed
* we had to add a patch to put fitpack back into a shape that makes f2c happy
* we need one more `-Wincompatible-function-pointer-types` fix upstream PR: https://github.com/scipy/scipy/pull/16934
More work split from #2976. This adds tracking for how many web loop
handles are active. It also adds handlers for when SystemExit or
KeyboardInterrupt are raised. The purpose of these is to allow us to keep
the Python interpreter alive until all tasks are completed, unless SystemExit
or KeyboardInterrupt is raised.
See https://github.com/hoodmane/pyodide/blob/cmdline-runner/tools/python.js for their use in context.
This commit changes how we load packages.
Before, we loaded all shared libraries first then all Python packages.
All shared libraries / Python packages were loaded in a random order,
which might cause a problem if there is a load-time dependency between libraries or between packages.
Now we load them in a topologically sorted order regarding dependencies.
Fix script double slash on script import
Remove extra shlash after PYODIDE_CDN_URL. It seems that the
var already ends with a forward-slash, so when building the CDN URL
`"{{PYODIDE_CDN_URL}}/pyodide.js"` that creates a double slash (ie:
`https://cdn.jsdelivr.net/pyodide/v0.21.2/full//pyodide.js`) and that is not a valid
url. No slash is needed between the variable `PYODIDE_CDN_URL` and
`pyodide.js`.
This initializes `pyodide.loadedPackages` from the file system
`importlib.metadata.distributions`. This makes it possible to handle the case
when the `site_packages` is persistent or packages are preinstalled there (say
with `--preload-file`).
Split off from #2976.
I was having a hard time getting the cryptography package compiled on the latest
version in the docker container because of the special requirements to get Rust
working. Added a small section to the documentation describing the steps I took
to make it work.
The command line runner in #2976 finally works, but it is a large change set so
I am planning to split it up. This is the first PR split off from there.
This PR adds a patch to Python to expose pymain_run_python. We cannot use the
public API Py_RunMain for this purpose because it finalizes the Python
interpreter with Py_FinalizeEx when it is done. If we start an async task with
Py_RunMain then it will segfault. pymain_run_python does a large amount of work
and reproducing it is undesirable.
I added an args parameter which accepts command line arguments. The private
entry point pyodide._main._run_main() executes the main Python entrypoint
without shutting down the interpreter and returns the return code.
This moves the fatal startup errors into a separate function and added `stderr`
redirection so that the error context can be included in the error message.
The new errors look like:
```
FatalPyodideError: Failed to import _pyodide module
Traceback (most recent call last):
File "/lib/python3.10/_pyodide/__init__.py", line 20, in <module>
blah()
File "/lib/python3.10/_pyodide/__init__.py", line 19, in blah
f()
File "/lib/python3.10/_pyodide/__init__.py", line 18, in f
raise Exception("oops")
Exception: oops
```
If Python startup code calls `exit` (for instance because `--version` or `--help`
was passed), then Emscripten calls `quit` which throws the error. The enclosing
environment catches that error and burns the evidence. This modifies `quit` to
record the fact that `exit` was called and rethrow the error (which will include the
exit code). Otherwise, trying to run the command line runner with `python --version`
will segfault.