Commit Graph

97 Commits

Author SHA1 Message Date
Christian Clauss 57f36ac6f8
Ruff is now compatible with Python pattern matching (#3650) 2023-03-13 22:45:06 +01:00
Gyeongjae Choi 52c033af9f
CI Add MacOS build (#3602) 2023-03-08 21:22:59 +01:00
Hood Chatham 861a758c3b
Add new `pyodide.ffi` JavaScript submodule with PyProxy subtypes (#3523)
This creates a new `pyodide.ffi` submodule and adds a bunch of new subclasses of
`PyProxy` to it.

There are three stages in which we are concerned with the behavior of the
objects we define:
1. at time of static typechecks
2. at execution time
3. when generating docs

Prior to this PR, the subtypes of PyProxy only work well for static type checks,
they work acceptably at runtime (just don't let the user access them), and the
docs don't look that great. This PR is primarily intended to improve the docs
for PyProxy, but they also make execution time checks work better: you can now
say `obj instanceof pyodide.ffi.PyCallable` instead of `obj.isCallable()` which
I is easier to understand and to cross reference against the documentation. I am
marking `isCallable` as deprecated.

I also made a bunch of edits and improvements to the docs.

I have deprecated `PyProxyCallable` in favor of `pyodide.ffi.PyCallable` and
`PyProxy.isCallable` in favor of `obj instanceof pyodide.ffi.PyCallable`.
`PyBuffer` has been renamed to `pyodide.ffi.PyBufferView` and a new `PyBuffer`
has been created which is a subtype of `PyProxy`.
2023-02-05 19:35:08 -08:00
Gyeongjae Choi 66812b8295
CI Show compressed size of main modules after build (#3526)
This adds a short helper script which shows a gzip and brotli compressed size of a file,
and uses it in CI to check compressed size of pyodide.asm.* after build in addition to
the original file size.
2023-02-03 21:25:38 -08:00
Hood Chatham 8c5ae6ff9e
Update description of github releases in docs (#3498) 2023-01-24 13:11:31 -08:00
Gyeongjae Choi 2f1716b575
Relocate files inside tools directory (#3358)
This PR relocates files inside `tools` directory so that `tools` directory doesn't
have to be vendored when creating xbuildenv.

- cmake, pyo3 config ==> moved to `pyodide-build`.
- venv python script ==> moved to templates, then copied to dist during build.
2022-12-26 20:00:24 -08:00
Hood Chatham 7422ab370d
Implement more detailed streams support (#3268)
Resolves https://github.com/pyodide/pyodide/issues/3112
This adds a carefully designed API for controlling stdin, stdout, and stderr. It changes
the default behavior to be a bit more useful, though in doing so introduces some mild
backwards incompatibility. In particular:

1. By default, stdin reads directly from `process.stdin` in node (as before) and raises an
error if in browser (not as before).
2. By default, stdout writes directly to `process.stdout` in node (before it called console.log)
and calls console.log in browser (as before).
3. By default, stderr writes directly to `process.stderr` in node (before it called console.warn)
and calls console.warn in browser (as before).
4. In all three cases, by default isatty(stdin/stdout/stderr) is true in node and false in browser
(in the browser it used to be true).
5. As before, if you pass `stdin`, `stdout`, or `stderr` as arguments to `loadPyodide`, `isatty` of
the corresponding stream is set to false.

The stdin function is now more flexible: we now correctly handle the case where it returns an
ArrayBuffer or ArrayBufferView.

I also added 3 new functions to set streams after Pyodide is loaded which offer additional
control:
* `setStdin({stdin?, error?, isatty = false})` -- Sets the stdin function. The stdin function takes no
arguments and should return null, undefined, a string, or a buffer. Sets and `isatty(stdin)` to 
`isatty` (by default `false`). If error is true, set stdin to always raise an EIO error when it is read.
* `setStdout({raw?, batched?, isatty = false})` -- If neither raw nor batched is passed, restore 
default stdout behavior. If rwa is passed, the raw stdout function receives a byte which it should
interpret as a utf8 character code. Sets `isatty(stdout)` to isatty (by default `false`). If batched is
passed but not raw, it sets a batched stdout function. The stdout function receives a string and
should do something with it. In this case it ignores isatty and sets isatty(stdout) to false.
* `setStderr({raw?, batched?, isatty = false})` -- same but with stderr.
2022-12-18 15:55:52 -08:00
Gyeongjae Choi d802fb3fdc
Remove pre-built docker image support (#3342) 2022-12-13 12:04:15 +09:00
Roman Yurchak d48a4f2193
Remove "Python initialization complete" log line (#3247) 2022-12-12 18:54:47 -08:00
Gyeongjae Choi cc7a734c49
Add `requirements/executable` key in meta.yaml spec (#3300)
Adds a new key in meta.yaml spec: requirements/executable which specifies the list of executables required to build a package. Unlike conda, we don't build or install these executables. This key exists just to halt build earlier

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2022-11-30 16:40:36 +09:00
Hood Chatham 65694d24dc
Performance tune command line runner reads from stdin (#3243)
The way the command line runner used to read from stdin was pretty inefficient.
This makes it better.
2022-11-12 22:53:45 -08:00
Hood Chatham 8523da0f36
Add a tool to allow us to embed wasm modules with hand coded wat (#3230)
This allows us to embed extra wasm modules into the output. This is split off of #3210.
We need this for #3210 since
1. We don't want to assume that externref is supported but we need to use it as part of
the JS Promise integration proposal. To handle this we segment off the externrefs into
separate wasm modules. If externref is not supported, we load most everything
successfully but these small modules fail to load

2. Even supposing that we know that externref is supported, there is no way to write C
code such that the compiled code uses externref. It's possible using the emscripten
assembly format, but that is less well documented and harder to use for our purposes
than wat.

This PR doesn't actually change anything by itself.
2022-11-10 14:22:59 -08:00
Hood Chatham 92a1a5c014
Fix exit in command line runner (#3241)
Don't set error code to 1 if the program calls exit(0)!
2022-11-09 21:37:36 -08:00
Hood Chatham 2cd616d441
Add support for loading .so files in command line runner (#3098)
This is needed to finish getting numpy tests working.

It won't work for packages that need shared libraries without some extra intervention.
ryanking's work in #3234 would help to fix this.

pip install scipy makes the command line runner extremely slow. Without scipy installed,
python -c 'print(1)' runs in about 1 second, but with it installed it takes more like 10 seconds
(time to load clapack_all.so and 111 different .so files in scipy, totaling 20 megabytes). We
have to load all of this despite the fact that we won't use any of it.
2022-11-09 13:05:01 -08:00
Gyeongjae Choi 6bfb9ba329
PKG Add geopandas, fiona, and GDAL (#3213) 2022-11-07 13:44:23 +09:00
Gyeongjae Choi 7d3e19b0f6
Correctly specify files to be packed in a npm package (#3168) 2022-10-12 13:54:12 +09:00
Hood Chatham 5f643fffb5
Fix cmdline runner when stdout doesn't have columns/rows attributes (#3156) 2022-09-29 10:41:20 +09:00
Gyeongjae Choi a916ea0b34
BLD simplify building CMake based packages (#3128)
This PR makes building CMake based packages easier.
- Introduce a custom toolchain file for Pyodide. It inherits most of settings from the original Emscripten toolchain file with some modifications. Packages built by pyodide-build will automatically use that toolchain file.
- Proxy cmake in pywasmcross.py, in order to proxy other compiler toolchains.
2022-09-22 10:42:26 +09:00
Gyeongjae Choi 024dcbe8f0
CI Fix ccache in package build (#3104) 2022-09-21 09:30:09 +02:00
Gyeongjae Choi c3a0ddb0c7
Add a version variable for Pyodide JavaScript Package (#3074) 2022-09-13 13:42:05 +09:00
Roman Yurchak f3ba7865b2
Run core tests in Safari (#2578)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-09-08 10:43:55 +09:00
Hood Chatham 3e2d7f29a5
Add command line runner main entry script (#3044)
This PR contains the changes from #3039 and #3040 which should be merged first.
The purpose is to add the main command line script from #2976.
2022-09-05 09:15:13 -07:00
Roman Yurchak c85e00806b
MAINT Switch to pytest-pyodide (#2893)
Co-authored-by: ryanking13 <def6488@gmail.com>
2022-07-31 19:00:45 +09:00
Gyeongjae Choi 84b103a810
Include README when deploying npm package (#2883) 2022-07-27 09:28:33 +09:00
Gyeongjae Choi 9d874d588b
MAINT Update pre-commit config (#2890) 2022-07-19 16:43:12 +01:00
Roman Yurchak 7f19462759
Don't rerun tests if collection fails (#2875) 2022-07-16 17:45:36 +09:00
Jo Bovy 8642b09449
Add astropy tests (#2865)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-07-13 11:19:29 +09:00
Hood Chatham cdb457bf5b
Add xbuildenv to github releases (#2850)
This adds a step that generates an xbuildenv to the circleci CI and
deploys it to github releases when we make a release. I also updated
the url in download_xbuildenv to point to github releases.
2022-07-10 10:58:39 +02:00
Gyeongjae Choi 7d7b7e899d
TST Make `pyodide-test-runner` installable (#2742) 2022-07-04 09:07:01 +02:00
Gyeongjae Choi 5935e5c7f9
Add sqlite3 binary to the docker image (#2807) 2022-06-30 13:22:03 +09:00
Hood Chatham 5fde2ae0a8
Add continuous deployment to npm (#2776) 2022-06-23 22:51:43 -07:00
Hood Chatham be331255f7
Pass -Zlink-native-libraries=no when building Rust (#2753) 2022-06-21 08:21:33 +02:00
Hood Chatham 734e91c4f5
MAINT Fix typo in bump-version (#2745) 2022-06-20 21:35:40 +02:00
Hood Chatham b427d36e58
Use nightly rust and simplify rust_emcc_wrapper (#2724) 2022-06-15 20:54:56 -07:00
Hood Chatham 6868d2e93c
Use -sSIDE_MODULE=2 when compiling rust (#2713) 2022-06-15 07:27:34 -07:00
Hood Chatham 9c305efc46
Fix cryptography build after emscripten update (#2683) 2022-06-14 14:54:07 +02:00
Hood Chatham dbbbbb67b2
Cryptography v36.0.2 w/ Rust (#2378) 2022-06-09 10:57:34 -07:00
Hood Chatham 6a0d66a5d7
MAINT Update gitignore for tools/symlinks (#2657) 2022-06-01 13:17:13 -07:00
Gyeongjae Choi a11f72e145
Simplify the version bump process (#2587) 2022-05-30 10:26:40 +09:00
Gyeongjae Choi b20b43bd66
MAINT Split conftest.py into modules (#2418) 2022-05-08 16:52:08 +09:00
Michael Droettboom 5700b867eb
Dependency checks for cmake (req. by emsdk) and libtool (req. by libffi) (#2423)
Earlier errors about these should make building smoother for new contributors.
2022-04-28 08:27:56 -07:00
Gyeongjae Choi 60d530801e
ENH Remove hard coded paths in `pyodide_build` (#2351)
We are pushing pyodide_build to PyPI as a Python package, but for now, 
installing pyodide_build from PyPI (i.e. pip install pyodide_build`) is almost 
useless because:

    there are bunch of hard-coded paths (e.g. Path(__file__).parents[2]),
    its dependencies are not specified in setup.cfg.

This PR is for mitigating this situation by removing hard-coded paths and
adding tests, and is also a preparation for our new CLI 
(https://github.com/pyodide/pyodide/issues/1977).
2022-04-09 13:41:10 -07:00
Hood Chatham f7b0f8c5cb
No replay (#2256)
Our package build process currently has a significant flaw: we first run setup.py, recording all compilation commands, then we rewrite these compilation commands to invoke emcc and replay them, and then we pray that the cross compiled executables ended up in the right place to go into the wheel. This is not a good strategy because the build script is allowed to implement arbitrary logic, and if it moves, renames, etc any of the output files then we lose track of them. This has repeatedly caused difficulty for us.

However, we also make no particularly significant use of the two pass approach. We can just do the simpler thing: capture the compiler commands as they occur, modify them as needed, and then run the fixed command.

I also added a patch to fix the numpy feature detection for wasm so that we don't have to include _npyconfig.h and config.h, numpy can generate them in the way it would for a native build. I opened a numpy PR that would fix the detection for us upstream:
numpy/numpy#21154

This clears the way for us to switch to using pypa/build (as @henryiii has suggested) by removing our dependence on specific setuptools behavior.

This is on top of #2238.
2022-03-13 11:39:06 -07:00
Henry Schreiner 4f8b0a0344
chore: more pre-commit checking (#2257) 2022-03-07 21:51:20 -08:00
Hood Chatham 5724bbc05c
MAINT use variables for Python version rather than hardcoding it (#2241)
* As much as possible, use variable for Python version rather than hardcoding it

This should make Python updates easier.
2022-03-03 19:13:58 -08:00
Henry Schreiner ed22c06e07
chore: pyupgrade 3.9+ (#2195) 2022-02-20 17:13:37 -05:00
Hood Chatham 8323987b39
Use wheels instead of file_packager (#2027) 2022-01-23 17:47:04 -08:00
Gyeongjae Choi a255d54f3f
Fix typo in micropip.install() error [skip ci] (#2004) 2021-11-27 10:57:36 +01:00
Owen Ou 6f65795cba
Fix download path of f2c in buildf2c (#1866) 2021-09-29 11:13:17 -07:00
Hood Chatham b322d6727a
Update prettier precommit and ci rules (#1747) 2021-07-25 08:02:33 -07:00