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.
This fixes#3011.
We attempted to make a test for this, but in all of our tests
`document.location === indexURL`. Our logic incorrectly used indexURL
instead of `document.location`.
As discussed in #2940, this PR changes the default value of the fullStdLib flag in loadPyodide to false.
This is a breaking change because for now distutils is not loaded by default.
Also, when fullStdLib is set to true, it loads all unvendored stdlibs except for test.
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Unvendor the standard library sqlite3 to reduce the size of the main module. It reduces the size of pyodide.asm.wasm around ~1.4MB.
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
The out of tree build system applies an abi tag based on `PYODIDE_EMSCRIPTEN_VERSION`
in `Makefile.envs`. Prior to this PR, it will happily accept the version of emscripten (say 3.1.18)
and produce a wheel tagged like it was produced from the expected Emscripten version (say 3.1.14).
This causes confusing errors due to ABI mismatch see igraph/python-igraph#560. This error message
should help prevent such confusion.