Commit Graph

322 Commits

Author SHA1 Message Date
Hood Chatham 3e05af6963
Using esbuild instead of rollup (take 2) (#3720)
Co-authored-by: webreflection <andrea.giammarchi@gmail.com>
2023-03-31 09:30:04 +02:00
Gyeongjae Choi 2046310460
ENH Support SDL-based packages and add pyxel (#3508)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2023-03-30 08:18:31 +00:00
Roman Yurchak bce105bd69 Revert "Using esbuild instead of rollup (#3679)"
This reverts commit be12f07ed9.
2023-03-29 22:08:03 +02:00
Andrea Giammarchi be12f07ed9
Using esbuild instead of rollup (#3679)
This PR removes *rollup* in favor of *esbuild*, ensuring `DEBUG` flag, when used, 
is available to the produced JS and the *umd* dance has been simplified, ditching 
the *amd* part from it as I think *amd* is kinda dead as module system.
2023-03-27 12:48:19 -07:00
Roman Yurchak 601d939fdd
Fix wheel compression with the JsDelivr CDN (#3667)
Set the MIME type for wheels and zip files to application/wasm to enable CDN compression. Also optionally disable compression in zip files and wheels to make the brotli compression by the CDN more efficient.

Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2023-03-21 09:11:47 +01:00
Gyeongjae Choi a9182030cd
Merge pyodide_py into python_stdlib.zip (#3621)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2023-03-04 11:05:12 +01:00
Gyeongjae Choi ba5545cbf1
Add private APIs to get Python version before bootstrapping Python (#3625)
Use them in Module.preRun to initialize the filesystem.
2023-03-03 10:19:43 +01:00
Gyeongjae Choi ed3ae1ba49
Download standard libraries in a zipfile (#3582) 2023-03-01 23:11:30 +01:00
Gyeongjae Choi c55bd2a823
Move webbrowser.py into pyodide-py (#3583) 2023-02-14 16:08:28 +09: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
Hood Chatham 5e26d9f1ae
Build libpyodide.a (#3335)
This is work towards unvendoring the Pyodide foreign function interface. 

Prior to this point, we included a large amount of critical functionality with `--pre-js`.
So we could create an archive called `libpyodide.a` with the object files but to use it
you would have to pass `--pre-js _pyodide.out.js` at link time. This embeds all of this
stuff in an object file called `pyodide_pre.o` which goes in our archive so you get all
the needed js runtime by linking it. 

Of course someone trying to use this still has to get the Python code onto the import
path, either using `--preload-file`, using Python to unpack it as a zip archive as we now
do, with zipimporter, or otherwise. They also will have to link `libpython.a` (is CPython
going to start distributing an Emscripten libpython?) and probably various other things.

We have to use a hack to inject the JavaScript code into the object files. The normal
`EM_JS` macro cannot handle arbitrary JavaScript code -- for example it fails with many
regex. Instead we manually generate write a C source file that does what we need using
`xxd`. The generated C code is similar to what `EM_JS` generates, but it uses an array
initializer rather than a string initializer for the characters avoiding the C preprocessor /
compiler's strange opinions about strings.
2023-01-26 17:22:05 -08:00
Hood Chatham c06f4d5dfb
DOCS Fix console.html deploy (#3510)
Put `console.html` in `app.outdir`.

This was needed because readthedocs/readthedocs.org PR 9888 moved the outdir
2023-01-25 09:31:06 -08:00
Hood Chatham 3b2952fc92
Python3.11 (#3252) 2023-01-23 19:45:59 -08:00
Gyeongjae Choi ef112108c9
Add rust toolchain to the pyodide-env docker image (#3441)
This adds rust toolchain into our docker image so we don't have to install it every time.

make rust command still exists, but I removed it from the docs. So now a user (who wants to build a package that requires rust) is responsible for installing rust toolchain in their build setup, which is reasonable I think.

Co-authored-by: josephrocca <1167575+josephrocca@users.noreply.github.com>
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2023-01-10 13:28:04 +09: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 653310a37d
NFC Use initialization function to load _pyodide_core (#3333)
This adds `_pyodide_core` to the init tab and initializes it using that. This is a small step toward unvendoring the Pyodide ffi.
2022-12-10 09:51:17 -08:00
Hood Chatham 68842baa16
NFC Move rollup.config.js to rollup.config.mjs (#3296)
My local build fails with:
```
RollupError: Node tried to load your configuration file as CommonJS
even though it is likely an ES module. To resolve this, change the
extension of your configuration to ".mjs", set "type": "module" in 
your package.json file or pass the "--bundleConfigAsCjs" flag.

Original error: Cannot use import statement outside a module
```
This fixes it.
2022-11-26 15:05:42 -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
Gyeongjae Choi 69b2d3f157
Add debug build option for js package (#3129) 2022-09-21 14:20:08 +09:00
Gyeongjae Choi 968f2c6f36
Keep webpackIgnore comments when building js package (#3132)
It adds terser config to not strip `/* webpackIgnore */` comments instead of
using sed after build.
2022-09-19 09:28:54 -07:00
Hood Chatham c53e229175
Fix webpack warnings and reenable webpack test (#3094)
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.
2022-09-12 15:00:54 -07:00
Hood Chatham e6e7d56752
MAINT Remove custom setuptools_rust commit (#3045) 2022-08-30 17:29:25 -07:00
Hood Chatham 325291ab87
Use upstream C++ error formatting support (#2828)
The logic that we are using to format C++ exceptions has been upstreamed. 
This will also work correctly with wasm exceptions.
2022-08-25 14:41:39 -07:00
Gyeongjae Choi e7a7bad1a9
MAINT Prevent `make rust` command from generating a temp file (#2984) 2022-08-18 09:26:31 +02:00
Gyeongjae Choi 26e45657a7
MAINT Build test and distutils stdlib modules with pyodide-build (#2979) 2022-08-18 13:55:16 +09:00
Hood Chatham 5fd96f9b27
Try again with deploying debug version (#2801)
I guess there has to be some trial and error with these. Since we
can't link `pyodide.asm.js` in the deploy docker image, we do it in
a separate step after `build-packages`. Because we have hard
coded `dist` everywhere, it's a little bit awkward building into
`dist-debug`. I do some rearrangements with `cp` and `mv` to hack
around this.
2022-06-28 10:16:23 -07:00
Hood Chatham deb344cd37
Update Rust nightly version (#2792)
Yesterday's nightly includes rust-lang/rust#98149 which allows us to remove the
PIC setting. This also means we won't ever have to put -Zbuild-std back in.
2022-06-26 21:21:34 -07:00
Roman Yurchak 8de2a04ab0
API Rename packages.json to repodata.json (#2749)
Closes #2747

 * renames packages.json to repodata.json
 * renames the corresponding JS and Python variables to be a bit more explicit.

Tangentially related to #795
2022-06-20 14:46:11 -07:00
Hood Chatham 060f1f4ba6
MAINT Use the patched version of setuptools-rust (#2735) 2022-06-20 09:28:19 +09:00
Hood Chatham b427d36e58
Use nightly rust and simplify rust_emcc_wrapper (#2724) 2022-06-15 20:54:56 -07:00
Hood Chatham c834085995
Use emscripten 3.1.13 (#2679) 2022-06-10 22:26:10 +02:00
Hood Chatham dbbbbb67b2
Cryptography v36.0.2 w/ Rust (#2378) 2022-06-09 10:57:34 -07:00
Gyeongjae Choi 0c63457b37
Remove tzdata from the build step (#2658) 2022-06-03 08:51:41 +09:00
Hood Chatham 951681cfba
MAINT Improve debug settings in Makefile.envs (#2648) 2022-05-30 17:16:55 -07:00
Gyeongjae Choi 829023c9af
MAINT Remove outdated commands in Makefile (#2576) 2022-05-19 15:09:24 +09:00
Hood Chatham 7fc1c2da8e
FIX Fix feature detection when `obj.constructor` is undefined (#2520)
Currently the following code fails:
```py
from js import eval
eval("Object.create(null)")
```
with:
```py
Traceback (most recent call last):
  File "<console>", line 1, in <module>
JsException: TypeError: Cannot read properties of undefined (reading 'name')
```
This fixes it.
2022-05-18 22:19:37 -07:00
Hood Chatham ccf97a9bc7
Remove npm-link step (#2480) 2022-05-04 14:06:55 -06:00
Mario Gersbach 0311cd1c20
ENH Add SHA-256 hash to packages.json entries (#2455) 2022-05-02 22:09:14 -06:00
Hood Chatham e5a46e520a
Fix npm package (#2394)
Various fixes to improve the npm package.

Switch to publishing the dist folder, fix indexURL for node, 
fix node commonJS import and ES6 import only publish core 
Pyodide interpreter to npm, download and cache other wheels 
on first use.
2022-04-17 21:10:03 -07:00
Hood Chatham 993940bbb9
Allow multiple loading of Pyodide instances (#2391) 2022-04-14 18:04:01 -07:00
Hood Chatham c4ebd374f7
Fix type declarations (#2396)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-04-14 10:55:42 +02:00
Hood Chatham 50af355e8c
Rename 'build' directory to 'dist' (#2387)
dist is both more accurate (the 'build' directory is normally where you do the build,
and normally consists of intermediate build artifacts no one cares about). dist also
occurs less frequently in the code base: after this change \bbuild\b has 466 matches,
whereas \bdist\b has 101 matches. build has 1072 matches whereas dist has 362.
2022-04-11 16:01:40 -07:00
Hood Chatham dfbf28856e
New keyboard interrupt patch from upstream (#2332) 2022-04-08 08:35:58 -07:00
Hood Chatham 0f2ce88edb
Rework core tests (#2265)
The goal of this commit is to add the capability of skipping specific tests by
glob pattern. Many core test sets have just one test that uses subprocess or
threads. Others have a few tests that are failing due to upstream problems in
emscripten. I went through and switched to skipping specific tests in as many
cases as I could. In modules where most or all tests use threading or
subprocess, I gave up and put a comment saying something like 35/50 tests fork
and I didn't want to bother to salvage the remaining ones.

In order to accommodate using patterns to skip specific tests (and also extra
comments) I switched the format of python_tests to a yaml file. This gives us
significantly more flexibility in the structure of the file and allows us to use
ruamel.yaml to update it. We gain a lot flexibility while reducing the length of
make_test_lists.py modestly from 108 to 78 loc.

In the future, hopefully we should be able to make fixes by deleting one skip
pattern and looking into why that particular test fails.
2022-03-22 13:41:43 -07:00
Hood Chatham a356fc4563
Fix requirejs compatibility (#2283) 2022-03-20 10:04:47 -07:00
Hood Chatham 0e1e2ac01c
Python 3.10 (#2225) 2022-03-17 15:48:56 -07:00
Hood Chatham 9feb50bb48
Remove numpy patches work around for chrome 89 bug (#2171) 2022-03-04 16:09:51 -08:00
Gyeongjae Choi fd8433a013
MAINT Refactor benchmark script (#2227)
One can select which benchmark (pystone, numpy, matplotlib, or all) to be run through command-line arguments.
We can divide each benchmark to separate CI jobs in the future if needed.
Moved pystone benchmark to benchmark directory, preventing it from being included in Pyodide release.
2022-03-02 10:11:36 -08:00
LeoPsidom 8798e1f2fd
Use ESM import in module type webworker (#2220)
Co-authored-by: root <root@ip-172-31-32-133.us-east-2.compute.internal>
2022-03-02 00:31:41 -08:00
Henry Schreiner 41b6db1bab
style: improve pre-commit (#2177) 2022-02-19 09:06:25 +01:00