Commit Graph

2835 Commits

Author SHA1 Message Date
Hood Chatham 68f1fdbf04
Only schedule Python coroutine if it's the result of calling an async function (#3994)
When we call a Python function from JavaScript, if the result is a coroutine
we have logic to automatically schedule it. This is so that a coroutine function
can be used as an event handler or otherwise as a drop in replacement for a JS
async function: when a JS async function is called, its execution is automatically
scheduled, whereas in Python an async function must be awaited or scheduled with
`create_task`. Contexts that expect JS async functions may not do any of these
things but still want the function to execute.

A confusing edge case that arises is when a coroutine is returned from a function
which is not a Python async function. This most often happens by accident, for example
 with `eval_code`. It's perhaps slightly unexpected that we schedule it in this case.
This PR adjusts it so that if a non-async python is called and it returns a coroutine,
we no longer schedule it.

One edge case that's still here is that if an async function returns a coroutine, that
coroutine will get automatically scheduled:

```js
pyodide.runPython(`
async def f():
   return g()

async def g():
   print("This is executed")
`);
pyodide.globals.get("g")()
```

This is because we attach the coroutine to a JS promise and if a JS promise resolves to
a thenable, the thenable is automatically thened. If we were sufficiently upset about this,
we could use a custom thenable that doesn't have this flattening behavior.
2023-07-17 05:52:54 +02:00
Tamás Nepusz 6c37b95ac2
Add `igraph` package (#3991) 2023-07-14 18:48:31 +09:00
Loïc Estève 1810fd9fdc
Upgrade scipy to 1.11.1 (#3996)
Upgrades scipy to its latest release 1.11.1 (released 28 June 2023).

I ran the scipy test suite locally and I did not notice any problematic issues.
There are some additional test failures for some tests that were added between
scipy 1.10.1 and 1.11.1. Most are due to Pyodide limitations. There is also
`scipy.stats.tests.test_multivariate` `test_cdf_against_generic_integrators`
that seems to indicate that `scipy.integrate.tplquad` is not converging but that
seems to be the case in scipy 1.10.1 too.
2023-07-13 17:22:27 -07:00
Owen Lamont 822276d974
Removed raise if failed check from the json and string response returns (#3986)
The previous logic raised an OSError if a response returned a status code of 400
or greater but it is useful to be able to retrieve the bodies from such
responses as they often contain additional information about the error
2023-07-12 13:48:40 -07:00
Hood Chatham f996914a96
Update changelog for v0.23.4 (#3982) 2023-07-06 22:05:30 -07:00
Hood Chatham fcb467d5f7
ENH Add environment variable to control 'exports' cli argument (#3973) 2023-07-06 19:52:45 -07:00
Kevin Hill 1012a3fed9
Add a exports/types field to package.json (#3975) 2023-07-05 22:22:01 +09:00
Guillaume Lemaitre 148eec4005
MNT Update scikit-learn to 1.3.0 (#3976) 2023-07-04 16:32:52 -07:00
Gyeongjae Choi 68e134284e
Fix netcdf4 test (#3977) 2023-07-04 15:20:59 +00:00
Hood Chatham 50b5e1ccb6 FIX Cap pydantic in pre-commit too 2023-07-01 09:00:33 -07:00
Tim Paine 72a1c0412f
FIX Version cap pydantic<2 (#3971) 2023-06-30 19:54:16 -07:00
Gyeongjae Choi b79b8913b9
Enable freesasa, lightgbm, opencv-python, and wordcloud (#3970) 2023-06-30 14:44:51 -07:00
कारतोफ्फेलस्क्रिप्ट™ f7562a3b0a
Allow customizing cache location for packages in Node (#3967)
This change allows users to customize where wheels are cached in Node.
This is important in the context of docker images and other cases where
the `node_modules` folder isn't writable.
2023-06-29 12:34:30 -07:00
Roman Yurchak 17be4f1347
Use pyodide-lock for pyodide-lock.json parsing in Python (#3949)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-29 16:45:06 +00:00
Gyeongjae Choi 1eaa80da9b
FIX set PYODIDE_ROOT when using Makefile out-of-tree (#3959) 2023-06-29 11:37:03 +00:00
Hood Chatham 2089d4238b
Only check if key in obj if obj[key] returns undefined (#3963)
This is a minor optimization in `JsObject_GetString`. We only need to check if `key in obj`
when `obj[key]` returns `undefined` to distinguish between missing and present but set
to `undefined`.
2023-06-28 20:18:28 -07:00
Hood Chatham b67660ff9d
BLD Add CPYTHON_DEBUG environment variable to request a debug Python (#3966) 2023-06-28 17:01:15 -07:00
Hood Chatham fb0dc034d4
Scipy: Fix gees calls from wasm invokes (#3960)
More fixes for scipy functions with incorrect signatures that are only called in try blocks
2023-06-28 17:00:30 -07:00
Hood Chatham c4a5090b7b
TESTS Add a couple of extra C++ exception tests (#3961) 2023-06-27 07:32:54 -07:00
Juniper Tyree 313bc4bb72
Add `netcdf4` package (#3910) 2023-06-26 21:20:53 +09:00
Gyeongjae Choi 8cd338b629
MAINT Relocate build environment management related methods (#3934)
Relocates methods that are related to the build environment management (common.py ==> build_env.py)
2023-06-26 21:20:12 +09:00
Hood Chatham a7a98c75a1
Fix failing hypothesis tests on the main branch (#3956)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-06-26 09:33:08 +02:00
Tom Nicholas 41b4276307
Update to xarray v2023.06.0 (#3951) 2023-06-25 22:48:09 +09:00
Hood Chatham 3bbb0d31dc
Replace void return value with int in quadpack.h (#3953)
In C++
```
try {
	some_func(arg1, arg2, ...);
} catch (SomeException e) {
	// ...
}
```
generates code like:
```
invoke_sig(some_func_ptr, arg1, arg2, ...);
```
where invoke_sig is a JS trampoline that does a JS try/catch. So in particular, if some_func is declared with the wrong type but it is only called in try blocks, then it will work anyways. But if instead of js exceptions you use wasm exceptions then it's back to "null function or function signature mismatch".
2023-06-23 16:25:21 -07:00
Hood Chatham 983f83ba1d
Remove assemble_wat (#3952)
This is dead code.
2023-06-23 16:09:43 -07:00
Roman Yurchak b4a4249278
MAINT pyodide-build: move setup.cfg to pyproject.toml (#3947) 2023-06-23 21:33:58 +02:00
Loïc Estève 1c27915653
Build scikit-image 0.21 with meson (#3874) 2023-06-23 17:28:44 +02:00
Hood Chatham 5fe0d2e302
Change the name of repodata.json to pyodide-lock.json (#3824) 2023-06-18 22:57:43 -07:00
Hood Chatham 9d8ed8e3b8
pytest-pyodide 0.52.2 (#3939) 2023-06-18 20:23:06 -07:00
Tim Sherratt 3be5be51e7
Upgrade pyodide-http to 0.2.1 (#3937)
pyodide-http (0.2.1) includes a bug fix for Firefox
2023-06-18 17:43:47 -07:00
Hood Chatham d7ca050fc8 Fix test_pyproxy_callable_prototype on firefox 2023-06-18 13:49:58 -07:00
Hood Chatham 31946ecb3a
Make PyProxy of a callable an instanceof Function (#3925)
Resolves #3924. Some code checks whether an object is callable with `instanceof Function`.
The correct way to check for callability is with `typeof x === "function"`, but ideally we want
to work with existing code that uses a less accurate callability check.

Make a copy of the PyProxy class which is a subclass of Function.
Since the difference between `PyProxy` and `PyProxyFunction` is an implementation
detail, we use `[Symbol.hasInstance]` to make them recognize the same set of objects
as their instances.

we also need some extra logic to filter out additional attributes that come from the
`Function` prototype.
2023-06-17 18:09:34 -07:00
Hood Chatham 005535b492
Changelog for 0.23.3 (#3936) 2023-06-17 17:49:12 -07:00
Hood Chatham 9012711ba0
Run replace_so_abi_tags on out of tree builds (#3927) 2023-06-17 13:39:33 -07:00
Gyeongjae Choi 1691d347d1
Don't set PYODIDE_ROOT inside xbuildenv installation function (#3922)
This is some cleanup after #3883.

- Make the `PYODIDE_ROOT` be modified only inside the `init_environment` function.
- Removes `__LOADED_PYODIDE_ENV`. I think it is redundant as we use `PYODIDE_ROOT` for a similar purpose.
2023-06-15 17:30:52 +09:00
Hood Chatham 54540364d4
Fix accessing Python reserved word attributes on js objects (#3926)
Removes some of the compatibility break introduced in #3617.
Update faq too.
2023-06-14 16:21:52 -07:00
Juniper Tyree e3789b8dfa
Add package `Cartopy` (#3909) 2023-06-14 13:15:41 +09:00
Hood Chatham 71cc8bc925 Revert "MAINT Use sigstore to validate Python source signature (#3916)"
This reverts commit 59bb655957.
2023-06-12 15:16:55 -07:00
Hood Chatham 59bb655957
MAINT Use sigstore to validate Python source signature (#3916)
This should make Python updates a little easier and more secure.

See: python.org/download/sigstore
2023-06-12 12:28:44 -07:00
Yan Wong ceda6ea388
Update tskit to 0.5.5 (#3923)
Tskit release 0.5.5 is a minor bugfix release containing a fix for for 32bit binaries. 
See 332d5b7461
2023-06-12 12:17:52 -07:00
Hood Chatham 19437388ff
Fix `from jsmod import *` (#3903)
Prior to this commit:
```js
pyodide.registerJsModule("xx", {a: 2});
pyodide.runPython("from xx import *");
```
raises:
```
ImportError: from-import-* object has no __dict__ and no __all__
```
Afterwards, it behaves as expected (a variable called "a" is introduced into globals equal to 2).
2023-06-12 09:46:16 -07:00
Hood Chatham dcc504cd46
Add an argument to loadPyodide to pass environment variables (#3870)
This also updates the command line runner to pass in all ambient environment
variables except that `HOME` is set to the working directory.

`homedir` is now deprecated. I added handling for `homedir` and `env.HOME`: 
if both are passed, raise an error, otherwise they mean the same thing.
2023-06-11 22:46:53 -07:00
Michael Weinold d7873bf6ac
Adding Package `peewee` (#3897) 2023-06-11 08:22:14 -07:00
Hood Chatham 3bf1075997
Use pytest-pyodide 0.52.1 (#3920) 2023-06-11 15:03:50 +09:00
Hood Chatham b9793f0c08
Switch _PyArg_Parser usage to be forwards compatible with Python 3.12 (#3919)
In Python 3.12 it's required to use designated initializers for `_PyArg_Parser`.
2023-06-10 19:06:53 -07:00
Hood Chatham 1b8dd35081
python3.12-compatibile python2js bigint conversion (#3918)
Using `Py_SIZE` on `PyLongObject` is no longer allowed in Python 3.12. Less
importantly, we are minorly overestimating the size of very large numbers here
since each digit has only 30 bits, so a 16 "digit" number has 480 bits and fits
into 15 u32s.
2023-06-10 19:00:24 -07:00
Hood Chatham dea990420e
NFC Adjust Makefile.envs so that it can handle prerelease PYVERSION (#3917)
This makes things work correctly if `PYVERSION` is set equal to e.g., `3.12.0b2`
2023-06-10 16:35:40 -07:00
Hood Chatham 1c57c72110
Add sequence methods to JsProxy of arrays (#3904)
Prior to this PR, internal Python code paths that use `PySequence_*` methods 
directly would fail on JS Arrays. To fix this, we implement `sq_length`, `sq_item`
and (for mutable sequences) `sq_ass_item.` I also added implementations for
the rest of the sequence methods `sq_concat` and `sq_repeat`.  Strangely
`sq_inplace_concat` already existed.
2023-06-08 11:00:14 -07:00
Hood Chatham ffa2dd7036
NFC Factor out common setup for rust packages (#3908) 2023-06-07 08:45:26 -07:00
Hood Chatham 09f903e8ab
NFC Update pre-commit rules to cover pyodide-build (#3911) 2023-06-06 14:21:03 -07:00