Commit Graph

2482 Commits

Author SHA1 Message Date
Roman Yurchak 3bc78d247c
Deploy pyodide-py in CI (#3356)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-12-15 10:22:23 +01:00
Gyeongjae Choi 0709ec0a26
Split building and installing packages in buildall (#3279) 2022-12-15 13:43:39 +09:00
Gyeongjae Choi 6c92594e2c
Fix misconfigured meta.yaml (#3354) 2022-12-15 11:40:46 +09:00
Roman Yurchak f0189de3f5
PKG Add pyodide-http (#3355) 2022-12-15 11:31:00 +09:00
Roman Yurchak 5f6ecca68d
Update to micropip v0.2.0 (#3347)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-12-14 09:11:19 +01:00
Gyeongjae Choi d0f1f7142b
Rename unvendored _hashlib to hashlib (#3349) 2022-12-14 09:05:17 +01:00
Deepak Cherian 62dcf9119f
Update xarray to 2022.12.0 (#3262) 2022-12-13 18:32:01 +01: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
Hood Chatham 33d1794a6e
Use a more robust method to improve our ModuleNotFound errors (#3263)
@ryanking13 added these very nice error messages to the `ModuleNotFound`
errors. However they introduce a few problems:
1. `find_spec` is supposed to return `None` or a spec and not to raise an error.
If it raises errors, it can cause trouble in code that tries to check if a module is
installed or not.
2. Other code that tries to add new import hooks has to know to insert them
before these error-raising import hooks.

See the discussion in #3262.

This instead patches `importlib._bootstrap` to create a function called
`_get_module_not_found_error`. We then can monkey patch this to modify
the error messages that `importlib` raises.

See Python issue: https://github.com/python/cpython/issues/100208
2022-12-12 18:35:51 -08:00
Hood Chatham 1410d2f526
Distinguish between sync and async JavaScript iterators when possible (#3339)
If a JavaScript has a `next` method and exactly one of `Symbol.iterator` or `Symbol.asyncIterator`
we use that to tell us whether we think `next` is sync or async. If both or neither of these
Symbols are present then we define both `__next__` and `__anext__`.
2022-12-12 17:33:46 -08:00
pre-commit-ci[bot] 4a35a5f80d
[pre-commit.ci] pre-commit autoupdate (#3345)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2022-12-13 00:08:49 +01:00
Hood Chatham 72414962a8
NFC Place js_flags in separate dict (#3338) 2022-12-10 12:18:17 -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 8560319738
Make fs timestamps have millisecond resolution rather than second resolution (#3313)
Resolves https://github.com/pyodide/pyodide/issues/3311
2022-12-10 09:50:08 -08:00
Jacques Boscq c9e47935c8
Add gensim package #2545 (#3326) 2022-12-07 00:08:49 +01:00
pre-commit-ci[bot] 4546f1b3d2
[pre-commit.ci] pre-commit autoupdate (#3325)
updates:
- [github.com/asottile/pyupgrade: v3.2.2 → v3.3.0](https://github.com/asottile/pyupgrade/compare/v3.2.2...v3.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-06 13:39:19 +01:00
Loïc Estève 09e18f78af
Update scikit-learn to 1.1.3 (#3324) 2022-12-06 13:39:00 +01:00
Loïc Estève 65d96d5532
Fix markdown in doc (#3323) 2022-12-05 20:17:12 +09:00
Hood Chatham 1c34d76482
Emscripten 3.1.27 (#3314) 2022-12-02 16:12:42 -08:00
pre-commit-ci[bot] 52e8609c54
[pre-commit.ci] pre-commit autoupdate (#3254) 2022-12-02 15:12:33 -08:00
Hood Chatham 29323915c3
Add a typeshed for the js module (#3298)
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2022-12-02 09:16:16 +01:00
Gyeongjae Choi 0c3545f06b
Unpin host Python patch versions in GHA (#3309) 2022-12-02 13:02:08 +09:00
Roman Yurchak 5a237d93aa
Package pyinstrument (#3258)
Co-authored-by: Nicholas Bollweg <nick.bollweg@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-12-01 14:40:19 +09:00
Hood Chatham e2f415d83b
Add athrow and aclose to JsProxy of an AsyncGenerator (#3299)
Continuing with my work on support for generators, this adds `athrow` and 
`aclose` for async generators.

Currently if you use `athrow` and the generator doesn't catch the error, it will
throw a double wrapped error. This is probably also a problem with async calls
Python --> Js --> Python because the way that we control the Python exception
lifetime only works correctly in synchronous contexts. Fixing this is a TODO.

Also, there is still a question of what to do with return values of async Javascript
generators. Currently I think they are available from Python as 
`async_stop_iteration_exception.args[0]`.
2022-11-30 11:10:42 -08:00
Hood Chatham c2ac865e20
Add test for MutableMapping methods on object_maps and fix bug (#3297)
This adds tests of all the `MutableMapping` methods for objects returned by 
`as_object_map`. They all worked but I was accidentally adding only the non 
mutating methods. I also added `JsMap` and `JsMutableMap` to `pyodide.ffi` 
and fixed it so that `isinstance` works correctly and mypy agrees with the usage.
2022-11-30 11:07:15 -08:00
dependabot[bot] e002c19af8
Bump minimatch from 3.0.4 to 3.1.2 in /src/js (#3306)
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
- [Release notes](https://github.com/isaacs/minimatch/releases)
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.0.4...v3.1.2)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-30 17:04:45 +01:00
Gyeongjae Choi c4a4ecbb04
Remove opencv-python fix in pywasmcross (#3307) 2022-11-30 17:04:18 +01: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 9e30fd8f97
NFC Add getTypeTag helper function (#3301)
We use `Object.prototype.toString.call` a lot so I thought it would
be good to add a helper function for this.
2022-11-29 10:14:40 -08:00
Gyeongjae Choi 6bf2550b67
Support loading shared libraries inside a wheel file globally (#3264) 2022-11-29 13:40:33 +09:00
Hood Chatham 1bb9eecef0
ENH Add support for asynchronous iterators to JsProxy (#3285)
This defines `__aiter__` for JavaScript objects with a `Symbol.iterator`. 
It also defines `anext` and `asend` for JavaScript objects with a `next` function.
These will fail with a suggestion to use `next`/`send` instead if the `next` function
does not return a promise.
2022-11-28 17:37:06 -08:00
Hood Chatham 3fe379355c
ENH Add send, throw, and close to JsProxy of generators (#3294)
This adds two new types to `pyodide.ffi`: `JsIterator` (which requires an object
to have a `next` method) and `JsGenerator` (which requires an object to be a true
JavaScript generator). The `JsIterator` type has `__next__` and `send` implementations,
and `JsGenerator` has also `throw` and `close` methods.

Unlike for Python generators, it's allowed to `send` a non-None value into a not-started
generator. We have no way to detect that the generator isn't started (JavaScript just 
ignores the value).

This also improves the error messages when `next` called on an object returns something
unexpected.
2022-11-27 21:57:24 -08:00
Hood Chatham a1e43afbc0
Make as_object_map subclass MutableMapping (#3295) 2022-11-28 09:13:22 +09: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 403ac54d43
Make JsProxy subclass Mapping or Sequence when appropriate (#2906)
This ensures that `PySequence_Check` of a `JsProxy` of a `Array` returns 
`True`, that `isinstance(jsproxy_of_array, Sequence)` returns `True`, and 
that `isinstance(jsproxy_of_mapping, Mapping)` returns `True`.

This makes it possible to use `JsArray` and `JsMap` with the `match` keyword.
See https://github.com/pyodide/pyodide/discussions/2903.
2022-11-26 12:04:11 -08:00
Hood Chatham 420660eb50
Add support to PyProxy for using async python generators from js (#3290)
This adds support for using async Python generators via PyProxy.
2022-11-25 20:00:38 -08:00
Hood Chatham 560364b98a
Add type field to PythonError (#3289) 2022-11-25 17:01:03 +09:00
Hood Chatham 5e13a0065d
Implement Mapping / MutableMapping methods for JsProxy of a Map (#3275)
This adds methods `keys`, `items`, `values`, `get`, `pop`, `setdefault`, `popitem`, 
`update`, and `clear` to a `JsProxy` of a map-like object. Since both Sequence-like 
objects and Map-like objects have a `pop` method but they have different
signatures, I had to split the `JsProxy` documentation class into several different
classes. This is probably a good idea anyways. As a followup I could set it up so
that `isinstance` and `issubclass` work correctly on these documentation classes.
2022-11-23 23:10:21 -08:00
Loïc Estève 114a685dae
Update numpy to v1.23.5 (#3284)
There are Pyodide-related fixes that made it into numpy 1.23. 
For a particular that I bumped into, see: 
https://github.com/pyodide/pyodide/issues/3203#issuecomment-1290551624.
2022-11-23 23:07:44 -08:00
Gyeongjae Choi 00a88b819c
Fix docstring error when loadPyodide is called with -OO option (#3282) 2022-11-24 09:59:40 +09:00
Hood Chatham ffbccde2b6
NFC Improve and simplify compute_typeflags function in jsproxy.c (#3283)
This improves compute_typeflags by moving the implementation
into JavaScript. This makes it more readable (because the conditions
are all in one place right next to each other rather than spread through
hiwire.c) and faster (because we don't have to call 15 different JavaScript
functions).
2022-11-23 15:45:38 -08:00
Hood Chatham e4edd7a4d2
Make various JsProxy classes implement issubclass and isinstance more helpfully (#3277)
Before we had a single `JsProxy` documentation class. Apparently mypy treated
it as `Any`. It had a bunch of methods on it that may or may not appear in
any specific ` sProxy`.

This does two things:

1. Split up `JsProxy` class into several synthetic subclasses like `JsArray`,
`JsBuffer` etc. These work much better with mypy, they should also improve
documentation layout and it helps when different subclassess have different
methods with the same name (e.g., `JsArray` and `JsMap` both will have `pop`
methods).

2. Make `isinstance` and `issubclass` work correctly both with synthetic `JsProxy`
classes like `JsArray`, `JsBuffer` etc and with `type(an_actual_jsproxy)`.

This cleans up the bootstrapping mess in `_importhook` because the `JsProxy`
from `_core_docs` works fine for instance checks now. 

I had to make changes to various other Python files 
because mypy now understands the types better and noticed that there were type errors.
For instance, this fixed several minor mistakes in the types in `http.py`.
2022-11-22 17:04:10 -08:00
Hood Chatham a00f871eef
NFC Add some forgotten static modifiers to jsproxy.c (#3281) 2022-11-21 20:27:15 -08:00
Hood Chatham 2df7a286ee
Emscripten 3.1.26 (#3280) 2022-11-21 17:34:49 -08:00
Hood Chatham 5ea48805a9
Add `as_object_map` method to JsProxy (#3273)
This adds a method which returns a new `JsProxy` that acts
like a container of the JavaScript object's `ownProperties`.
2022-11-21 16:59:47 -08:00
Hood Chatham 30ed76fd3e
Add _js_type_flags to JsProxy types (#3272)
This adds a static variable that allows us to access the type flags for jsproxies.
I also did a little bit of cleanup in `jsproxy.c`.
2022-11-21 16:58:56 -08:00
Gyeongjae Choi 923aea8221
Pin setuptools version (#3278) 2022-11-21 16:03:53 +09:00
Hood Chatham 6416122130
DOCS: Get rid of those damn parentheses at the end of type names (#3270)
This has been bothering me for a long time. Fix discovered by trial and error.
The parens are getting added here:
https://github.com/sphinx-doc/sphinx/blob/master/sphinx/roles.py#L87
2022-11-20 18:52:19 -08:00
Gyeongjae Choi 059cca3f48
Fix broken libmpfr link (#3276) 2022-11-20 18:45:39 -08:00