Commit Graph

844 Commits

Author SHA1 Message Date
Hood Chatham 99a5e21287
Fix `eval_code` (#3580)
This fixes eval_code / eval_code_async / CodeRunner.run / CodeRunner.runAsync so that the defaults for globals and locals work as documented. Resolves #3578.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-03-03 08:54:20 +09:00
Joe Marshall 0fdf9a80fa
Add Fastparquet (#3590) 2023-03-02 14:46:58 +09:00
Christian Clauss b19e276cfa
Python 3.11.2: Set PYODIDE_IMAGE_TAG in run_docker (#3620) 2023-03-02 02:10:53 +01:00
Christian Clauss 154fbed9fa
Upgrade to Python v3.11.2 (#3614) 2023-03-01 23:57:17 +01:00
Gyeongjae Choi ed3ae1ba49
Download standard libraries in a zipfile (#3582) 2023-03-01 23:11:30 +01:00
Jeff Glass f3360876be
Add FAQ, Docs for working around JS Objects named like Python Keywords (#3616) 2023-03-01 16:57:08 +09:00
Gyeongjae Choi c99584d4b8
FIX Change rust packages not to build concurrently (#3607)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2023-02-27 14:55:03 +09:00
Gyeongjae Choi 0d5bd851fe
Use loky.cpu_count() instead of os.cpu_count() (#3598) 2023-02-22 07:53:19 +09:00
Gyeongjae Choi 994ce5111f
BLD Add DISTDIR variable (#3584) 2023-02-17 08:25:42 +09:00
messense 0be3c6d9fa
Fix activating pyodide venv command docs (#3586) 2023-02-15 16:34:07 +09:00
Gyeongjae Choi c55bd2a823
Move webbrowser.py into pyodide-py (#3583) 2023-02-14 16:08:28 +09:00
Feodor Fitsner 2f305cfec7
Add Flet to Related Projects (#3571) 2023-02-10 12:25:59 -08:00
Gyeongjae Choi b6fc9e7b1d
Add --no-user flag when installing packages in xbuildenv (#3562) 2023-02-10 09:17:53 +09:00
Gyeongjae Choi 68e42b1867
ENH Autodetect the number of cores when invoking `pyodide build-recipes` (#3559)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2023-02-10 08:56:42 +09:00
Gyeongjae Choi 189e49e892
FIX Escape nbsp in console.html (#3558)
Resolves https://github.com/pyodide/pyodide/issues/3337

In Firefox if one writes anything with spaces then tries to copy-paste the input to a standard Python REPL, one gets,

SyntaxError: invalid non-printable character U+00A0

this is because spaces are replaced by the non-breaking space character.

This patch replaces non-breaking space characters with normal space characters in the repl.
2023-02-09 10:34:05 -08:00
Hood Chatham 84ef7fa76d
Fix isPyProxy so that it works correctly with multiple Pyodide interpreters (#3545)
This removes code so that we use the default `instanceof` behavior.
The added test fatally fails without this patch.
2023-02-07 16:03:43 -08:00
Roman Yurchak 48258ff146
Replace isort, flake8, pycln and pyupgrade by ruff (#3522)
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2023-02-07 08:35:20 +09:00
Hood Chatham 5780584407
Docs: Minor improvements (#3546) 2023-02-06 08:45:12 +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
Joe Marshall ba3a8d7eb8
Reproducible package builds (and requirements.txt support) (#3469)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-04 14:55:09 +01:00
Hood Chatham c221532c8c
Disable NODEJS_CATCH_EXIT (#3542) 2023-02-04 14:50:14 +01:00
Gyeongjae Choi 71d466df2f
DOC Fix version warning CSS (#3533)
Close https://github.com/pyodide/pyodide/issues/3513
2023-02-04 14:49:11 +01:00
Gyeongjae Choi f943739e8f
ENH Add --no-deps parameter to build-recipes CLI (#3520)
This adds `--no-deps` parameter to `pyodide build-recipes` CLI, which is a replacement for `pyodide_build buildpkg` entrypoint.

Ref: https://github.com/pyodide/pyodide/issues/2879
2023-02-03 21:31:46 -08:00
Gyeongjae Choi c633565983
Fix console.html url in docs (#3532) 2023-02-02 10:39:42 +09:00
Hood Chatham 20e92c37ca
DOCS, MAINT: Replace :any: xrefs with more specific types (#3531)
This leads to more consistent rendering (functions and methods get parens after
them) and reduces chances of warnings about getting the wrong link. It is also
possible to use `~fully.quallified.name` to just show `name` if we use a specific
reference type, but it doesn't work with `any` for some reason.
2023-02-01 11:00:58 -08:00
Gyeongjae Choi dcdc1e6941
Unvendor pydoc_data and _pydecimal (#3525)
Removes / unvendors some python modules:

- Remove `_aix_support.py`, which is for supporting IBM AIX OS.

- Unvendor `_pydecimal.py`.
  - _pydecimal is a pure Python implementation of `decimal` module. [Importing `decimal` fallbacks](https://github.com/python/cpython/blob/main/Lib/decimal.py) to `_pydecimal` if the C-implementation `_decimal` is not available. In our case, _decimal is available, so _pydecimal will not be normally used. 

- Unvendor `pydoc_data`.
  - pydoc_data contains [a large (~700KB) dictionary](https://github.com/python/cpython/blob/main/Lib/pydoc_data/topics.py) for explaining python builtins. This is mostly used when `help("...")` is called.
2023-02-01 11:00:17 +09:00
Gyeongjae Choi f4f097542c
Fix misplaced changelog entry [skip ci] (#3527) 2023-02-01 10:18:10 +09:00
Gyeongjae Choi f50c749c9a
Apply upstream cpython commits to relocate test directories (#3507) 2023-01-30 13:34:33 +09:00
Gyeongjae Choi 16d494b22b Disable AUTO_JS_LIBRARIES and AUTO_NATIVE_LIBRARIES flags (#3505) 2023-01-30 10:43:34 +09:00
Hood Chatham 122facf069
Emscripten 3.1.31 (#3517) 2023-01-27 20:05:21 -08:00
Gyeongjae Choi 328a9ffc34
Add tag key in meta.yaml spec (#3444)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2023-01-27 13:31:26 +09: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 441cddea0c
Refactor conf.py (#3512)
Instead of putting stuff behind `IN_SPHINX`, define functions and call them from the `setup` function. 
In these functions, if we want to expose variables as part of the config we have to assign to `app.config.some_var` which is more explicit.

We still have to make the path change at top level. To improve this, in the future we should:
1. rename the sphinx_pyodide folder to sphinx-pyodide
2. add a `pyproject.toml` and `setup.py` so we can `pip install -e` it
3. instead of modifying the path, source the virtual environment
2023-01-26 15:36:22 -08:00
Hood Chatham 74686832b9
ENH Make JS Errors work like other special JS types (#3455)
Up to this point, we've used this dynamic subclassing method for
producing JsProxies for everything but errors. For errors, we make
a wrapper which is not a JsProxy that inherits from Exception and
give the wrapper a "js_error" attribute that points to an actual
error. We also make python2js know about this wrapper so it can
unwrap it. But the raw js_error object is a bit weird. There isn't
anything terrible about this situation but it is mildly unsatisfying.

This changes it so that errors subclass both JsProxy and Exception.
To do this we need to:
1. ensure that they have compatible memory layouts, and
2. convince Python that they have compatible memory layouts

I switched to using a union for the different subtypes of JsProxy
that need extra space: JsCallable, JsBuffer, and JsError. We need
js to be at the end so it won't get in the way of the BaseException
memory layout. I added _Static_asserts to double check that the
memory layouts do in fact agree.

To convince Python that they have compatible memory layouts, we have
to temporarily tell it that JsProxy is a subtype of BaseException.
To do this, we just set JsProxy.__mro__ = (BaseException,) before
creating the type and then restore it afterward.
2023-01-26 11:08:46 +09:00
Hood Chatham 9161c34fb3
Reorder changelog for 0.22.1 (#3509) 2023-01-25 15:58:09 -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 1c2bf92a3f
Improve messages in case of system exit (#3496)
This prints a better set of error messages in case someone calls os._exit() or in C code exit() is used.
In the future we might like to do something better here, but for now at least we can print a clear
error message.
2023-01-24 18:11:11 -08:00
Hood Chatham 8c5ae6ff9e
Update description of github releases in docs (#3498) 2023-01-24 13:11:31 -08:00
Hood Chatham 036f9cb545 Revert "0.23.0a1"
This reverts commit 2eaee0673d.
2023-01-24 07:30:10 -08:00
Hood Chatham 2eaee0673d 0.23.0a1 2023-01-23 21:45:09 -08:00
Hood Chatham 3b2952fc92
Python3.11 (#3252) 2023-01-23 19:45:59 -08:00
Hood Chatham 3f845c87a1
Pass same environment variables to out of tree builds as in tree ones (#3495)
Resolves https://github.com/pyodide/pyodide/issues/3493
2023-01-23 17:09:31 -08:00
Hood Chatham d3c2a6dfa8
Fix setStdin to insert a null after each buffer if autoEOF parameter is true. (#3488)
Resolves https://github.com/pyodide/pyodide/issues/3413
2023-01-23 17:07:59 -08:00
Hood Chatham dc514421ad
DOCS Build emsdk before python (#3489) 2023-01-24 09:11:22 +09:00
TheOnlyWayUp 47fad2e91f
DOCS Update micropip docs link on Website (#3494)
[skip ci]
2023-01-23 17:58:38 +01:00
Hood Chatham 485e806383
Make sure pyodide config doesn't output anything extra (#3483)
Resolves https://github.com/pyodide/pyodide/issues/3430
2023-01-22 08:24:58 -08:00
Hood Chatham af4158da77
Don't check emscripten version when creating pyodide venv (#3485)
Resolves https://github.com/pyodide/pyodide/issues/3472
2023-01-22 08:21:03 -08:00
Hood Chatham 1b2375f76c
Fix `from pyodide.ffi import *` (#3484)
Also remove almost everything from `_core.py` and moves it to `ffi/__init__.py`.
Micropip imports `IN_BROWSER` from `pyodide._core` so we leave that in there.

Resolves https://github.com/pyodide/pyodide/issues/3432
2023-01-22 08:19:48 -08:00
Hood Chatham 8a26af4f76
DOCS Improve JavaScript type rendering (#3481) 2023-01-22 09:26:42 +01:00
Gyeongjae Choi 8d7137f112
Fix incorrect error messages in ModuleNotFoundError (#3435)
Close https://github.com/pyodide/pyodide/issues/3423
2023-01-22 09:20:19 +01:00
Hood Chatham 69d7b4e099
Remove napoleon_fixes (#3479)
I upstreamed all of this into sphinx-autodoc-typehints.
2023-01-21 17:44:20 -08:00
Hood Chatham 6972ff101d
DOCS Add sphinx cross referencing to MDN docs using intersphinx (#3477) 2023-01-20 11:21:44 +09:00
Hood Chatham 2801ffb0db
More updates to docstrings (#3466)
I added a new decorator called `@docs_argspec` to override the argument specification
of a function used in the docs by setting `func.__wraps__` to a fake function. This only
happens when building the docs, normally it is a no-op.

`@docs_argspec` is needed when using `@overload` because mypy requires the argspec
of the main function to be at least as general as the argspecs of all the overloads, which
causes suboptimal rendering in the api docs.
2023-01-18 14:13:37 -08:00
Hood Chatham 9b58bf4294
DOCS Remove ensure_argument_types and use autodoc-typehints feature for this (#3475)
Turns out there was a setting for this. Should have read the docs!
2023-01-18 14:13:17 -08:00
Gyeongjae Choi 5523b1397f
Implement pycompile option in pyodide create-zipfile CLI (#3463) 2023-01-18 10:00:18 +01:00
Hood Chatham eca4b1615e
Add sphinx-design, fix tabs (#3473)
In #3461 I dropped `sphinx-panels` but of course we *were* using it. It has a successor called
`sphinx-design` which works with sphinx 5.x (still not 6.x but we have several packages that cap 
sphinx <6). I also updated the use of the tabbed directive to the new sphinx-design api.
2023-01-17 22:35:30 -08:00
Hood Chatham 920f2e1679
DOCS: Help Spinx find ffi types (#3465)
The `pyodide.ffi` stuff is defined in `_pyodide._core_docs`. We don't want `_pyodide._core_docs` to appear in the documentation because this isn't where you should import things from so we override the `__name__` of `_pyodide._core_docs` to be `pyodide.ffi`. But then Sphinx fails to locate the source for the stuff defined in `_pyodide._core_docs`. This patches `ModuleAnalyzer` to tell it to look for the source of things from `pyodide.ffi` in `_pyodide._core_docs`.
2023-01-17 22:34:15 -08:00
Hood Chatham 3cc6ac7873
Minor docs fixes (#3467)
Remove the property prefix from properties, add a link for ast.Module.

Previously this included more significant changes but they have been upstreamed into sphinx-autodoc-typehints.
2023-01-18 14:00:39 +09:00
Hood Chatham d9d7078d5c
Emscripten 3.1.30 (#3471) 2023-01-17 15:31:36 -08:00
Hood Chatham 4ff8687965
DOCS Fixes for shortcomings of napoleon (#3451)
I opened a PR for one of the Napoleon changes:
https://github.com/sphinx-doc/sphinx/pull/11131
But we use Sphinx v5.3 so even if we upstream Napoleon fixes into Sphinx v6.x, 
we won't get to use them for a while.
2023-01-16 19:59:07 -08:00
Hood Chatham e4421b94aa
Update docs requirements (#3461)
With this we can get up to Sphinx 5.3.0 (from Sphinx 4.5.0). I dropped sphinx-panels
since it has a version pin on Spinx < 5 (we don't seem to use it anyways). I moved to
sphinx-book-theme 0.4.0rc1 since version 0.3.0 pins Sphinx < 5. 

This is relevant because new versions of sphinx-autodoc-typehints require Sphinx>=5.3
so we can't pull in my fixes to sphinx-autodoc-typehints.

In the future, I would like for version caps (==, <, <=, and =~) to have comments
explaining them. I removed all the version caps since none of them seem to actively break.
In particular, we can now use jinja2 version 3 so we don't have to pin docutils 0.16.
2023-01-16 18:47:20 -08:00
Gyeongjae Choi eb7b80bb3e
Replace print statements with rich in pyodide-build (#3442) 2023-01-16 13:46:38 +09:00
Hood Chatham f55bb2e423
Cleanup of documentation configuration (#3448) 2023-01-14 15:01:20 +01:00
Gyeongjae Choi ae4492a1fd
Add a CLI command to create a zipfile of Python libraries (#3411)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2023-01-14 14:59:42 +01:00
Eli Lamb 3ea89996a6
Added react-py to Related Projects (#3450)
Resolves issue #3447
2023-01-13 19:03:06 -08:00
Gyeongjae Choi 094a6dafcf
FIX Append --fresh flag to let cmake ignore existing cache (#3445)
Resolve https://github.com/pyodide/pyodide/issues/3425
2023-01-13 18:41:29 +01: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
Hood Chatham b0b07efe94
Update to sphinx-js 3.2.1 (#3429) 2023-01-07 13:23:56 +02:00
Hood Chatham aeb066bbce
DOCS Improve rendering of JavaScript property types (#3426) 2023-01-06 00:06:04 -05:00
Joe Marshall 76581a7d28
Get deps from pypi during build (#3310) 2023-01-05 08:45:20 +09:00
Roman Yurchak e8f8324eb2
Add CLI command to py-compile wheels (#3253)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2023-01-04 17:07:07 +02:00
Hood Chatham e90154f3e2
DOCS Use autodoc typehints and make various improvements to autodoc rendering (#3405)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2023-01-04 11:51:09 +02:00
Jeff Glass 57d4412b74
DOCS Fix link to out-of-tree-builds documentation (#3409)
[skip ci]
2023-01-03 22:50:56 +02:00
Roman Yurchak 9888f13bc1
DOC Fix duplicate version section name in the changelog (#3406)
[skip ci]
2023-01-03 18:13:46 +02:00
Gyeongjae Choi 8e965e57d4
0.22.0 (#3389)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2023-01-03 20:34:25 +09:00
Gyeongjae Choi f654b9580d
DOC Rearrange out-of-tree build doc (#3404) 2023-01-03 15:09:15 +09:00
Hood Chatham 1169cf59a3
Hide deprecated arguments from docs (#3396)
This adds a mechanism to hide deprecated or private arguments from the documentation and
applies it to errorCallbackDeprecated.
2023-01-03 13:26:37 +09:00
Hood Chatham bddcc22dda
DOCS Fix the async prefix, improvement to summary table format (#3399) 2023-01-02 10:33:55 +09:00
Hood Chatham df3898f4c3
Fix 'version' in api docs (#3398)
The documentation generation seems to get confused by the default export and
displays the `version` field as `default` instead.  This switches to a normal export.
2023-01-01 10:44:35 -05:00
Gyeongjae Choi 4114f20986
DOC Fix various sphinx warnings (#3391)
Fix various sphinx build warnings.

I removed **all cross-references** in the changelog document. It causes trouble 
whenever we make an API change.
For example, Hood did some great work of splitting JsProxy classes into subclasses
in this release, but the changelog of older versions still contains cross-references to
`JsProxy.<method>` which doesn't exist anymore. It doesn't make sense to change it
to e.g. `JsBuffer.<method>` or `JsArray.<method>` as those classes are not available in
that version, so I think the reasonable option would be not using cross-references.
2022-12-27 19:17:23 -08:00
Hood Chatham 4f15bc8cc9
Add type parameters to JsProxy subtypes (#3387)
Added type parameters to `JsArray`, `JsMap`, `JsMutableMap`, etc. Based on 
[the typesheds for typing](https://github.com/python/typeshed/blob/main/stdlib/typing.pyi).
I skipped `JsCallable` and a few other more complicated types, those can be handled later.
2022-12-27 19:16:23 -08:00
Hood Chatham 158376f710
Improve mypy typing for pyodide package (#3385)
The way we were handling the "routing" in `_core.py` (where in browser things are
imported from `_pyodide_core` and otherwise things from `_pyodide._core_docs`)
made mypy type a bunch of things as `Any`. 
This switches to doing the imports from `_pyodide_core` with reflection that mypy
cannot understand so it will correctly type all of the methods with their types from
`_pyodide._core_docs`.

This created some new type errors, so I also made various fixes to make things
typecheck again.
2022-12-26 10:20:05 -08:00
Hood Chatham 6bca0c6ace
Fix scipy exception handling (#3384)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
Resolves https://github.com/pyodide/pyodide/issues/3382
2022-12-23 09:46:09 +01:00
Gyeongjae Choi ab93a0d747
Add `pyodide config` command to show config variables used in Pyodide (#3376) 2022-12-23 09:20:23 +01:00
Hood Chatham 83ea44728a
Don't destroy roundtrip PyProxies automatically (#3369)
* Don't destroy roundtrip PyProxies automatically

There's a bunch of places where we want to destroy a `PyProxy` if it is being
handed back into Python. This way, if the user wants to keep the proxy around
they can return a copy() of it (whereas otherwise they would have no way to
destroy it after the JavaScript execution is ended).

```js
function new_dict(){
  const dict = pyodide.globals.get("dict");
  const result = dict([[1,2],[3,4]]);
  return result;
  // Proxy is destroyed after it is returned!
}
```

If the `PyProxy` has roundtrip set, however, it is generally a bad idea to
destroy it in these cases. In many cases, this means that the object returned
to Python is actually unusable (because we get a destroyed double proxy).

One slightly annoying question is how to deal with the case where (1) we
want the return value NOT to be destroyed and (2) it may or may not be roundtrip

```
function f(px){
   // We don't want px to be destroyed so we have to return a copy (the copy
   // gets destroyed instead). But if px is roundtrip then the copy is also
   // roundtrip and neither gets destroyed so there is a leak. What to do???
   return px.copy();
}
2022-12-23 09:24:58 +09:00
Roman Yurchak fdbcc087e2
Add Pyodide CLI documentation (#3367)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-12-22 11:24:28 +01:00
Gyeongjae Choi 8c6b0a365a
Remove interface.ts and fix doc build error (#3377) 2022-12-21 16:28:05 +09:00
Hood Chatham 28bd91fd2f
DOC Update docs on new-packages.md (#3374)
[skip ci]
2022-12-20 10:20:48 +01:00
Hood Chatham 68f7fa06d9
Rearrange changelog for v0.22 (#3370) 2022-12-19 08:09:00 -08:00
Hood Chatham 3a28adcb82
Add generator argument lifetime handling (#3317)
This adds lifetime handling to the arguments of JavaScript sync and async generator
functions and to the arguments of `send` and `asend`. The arguments and the `send`
values are kept alive until the generator finishes. This is accomplished through a
wrapper around the generator. The return value of the generator is not destroyed by
the wrapper, but it will get destroyed in the C code for `asend`/`athrow`/`aclose` (unless
the generator wrapper is sent back to JavaScript and called directly).
2022-12-18 18:46:56 -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 cb29aca290
Patch ctypes.util.find_library to support Emscripten platform (#3353) 2022-12-18 11:20:00 +01:00
Péter Ferenc Gyarmati f1f924c5f3
docs: fix typos (#3359) 2022-12-16 11:13:52 -08:00
Hood Chatham 778fdf9f87
Add support for `throw` and `return` to PyProxy of a generator (#3346)
Continuing the work on generator support, this adds throw and
return to PyProxy of generators and async generators.
2022-12-15 15:41:52 -08:00
Gyeongjae Choi 0709ec0a26
Split building and installing packages in buildall (#3279) 2022-12-15 13:43:39 +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
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