Commit Graph

146 Commits

Author SHA1 Message Date
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 0a1d87d45f
Customize build type in indexURL used by console.html (#3702)
[skip ci]
2023-03-29 22:06:59 +02:00
Roman Yurchak de7ac903e7
DOC Remove pyodide-build CLI from the documentation (#3699)
[skip ci]
2023-03-27 09:58:13 +02:00
Loïc Estève 21c4d5c23c
DOC use MyST inline attrs for external links (#3639)
[skip ci]
2023-03-07 18:10:27 +01:00
Hood Chatham 97d17373f2
Handling for reserved Python keywords as JsProxy attrs (#3617)
Resolves #3615. Things like `from` and `finally` are reserved keywords in Python and so `a.finally` 
is a `SyntaxError`. This automatically reroutes `a.from_` on a `JsProxy` to refer to `a.from` so it
can be used reasonably conveniently from Python.
2023-03-03 11:13:40 +01:00
Hood Chatham 959ceb9d57
Add locals option to runPython and runPythonAsync (#3618) 2023-03-03 10:09:02 +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 c55bd2a823
Move webbrowser.py into pyodide-py (#3583) 2023-02-14 16:08:28 +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
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
Hood Chatham 8c5ae6ff9e
Update description of github releases in docs (#3498) 2023-01-24 13:11:31 -08:00
TheOnlyWayUp 47fad2e91f
DOCS Update micropip docs link on Website (#3494)
[skip ci]
2023-01-23 17:58:38 +01: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 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
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
Roman Yurchak fdbcc087e2
Add Pyodide CLI documentation (#3367)
Co-authored-by: Gyeongjae Choi <def6488@gmail.com>
2022-12-22 11:24:28 +01: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
Péter Ferenc Gyarmati f1f924c5f3
docs: fix typos (#3359) 2022-12-16 11:13:52 -08: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
Roman Yurchak d48a4f2193
Remove "Python initialization complete" log line (#3247) 2022-12-12 18:54:47 -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
Loïc Estève 16083881eb
Fix Pyodide REPL URL (#3244)
* Fix Pyodide REPL URL

* Use stable URL in quickstart.md

* try relative URL for Pyodide REPL

* use HTML rather than md syntax

* Revert "use HTML rather than md syntax"

This reverts commit e911f17181.

* Fix relative URL

* Use rst trying to avoid myst_parser cleverness

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [skip ci] trigger CI

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-11-10 15:53:37 +01:00
Gyeongjae Choi 3a7e1ccbd4
DOC Add a FAQ entry for async filesystem usage (#3222)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2022-11-04 11:04:35 +09:00
Gyeongjae Choi f48893c33a
Add _hashlib to unvendored stdlib (#3206) 2022-10-26 10:59:01 +09:00
Gyeongjae Choi 7dfee03a82
ENH Add API for mounting native file system (#2987)
This PR adds an API pyodide.mountNativeFS which mounts FileSystemDirectoryHandle into a Pyodide Python file system.

Note that there are some limitations such as:

- File System Access API is only supported by Chromium-based browsers (Safari also implements a portion of it but they only support Origin Private File system so it is not very useful for common users).
- The file system is asynchronous, so one needs to call syncfs to persist changes.

Since it is asynchronous, it does not require any WebWorker, SharedArrayBuffer, or Atomics. But I think we can extend this to a synchronous version using those features
2022-09-30 09:24:53 +09:00
Gyeongjae Choi a1b72c6fa3
DOC Remove warnings about pyodide-cdn2.iodide.io (#3150)
[skip ci]
2022-09-26 09:46:19 +02:00
Aierie 4b2191ebd6
Allow use with (module-type) service workers (#3070) 2022-09-17 21:35:32 -07:00
Hood Chatham aa4d22341a
DOCS Add faq entry on importlib.invalidate_caches (#3102)
[skip ci@
2022-09-14 21:19:43 +02:00
pre-commit-ci[bot] efcca8be91
[pre-commit.ci] pre-commit autoupdate (#2928) 2022-09-13 15:12:40 -07:00
Roman Yurchak 853f88c1ae
DOC Improve documentation on loading packages (#3064)
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2022-09-07 08:53:55 +02:00
Prete f203a2a88d [Docs] Fix 'Loading packages' CDN url (#3052)
Fix script double slash on script import

Remove extra shlash after PYODIDE_CDN_URL. It seems that the
var already ends with a forward-slash, so when building the CDN URL
`"{{PYODIDE_CDN_URL}}/pyodide.js"` that creates a double slash (ie:
`https://cdn.jsdelivr.net/pyodide/v0.21.2/full//pyodide.js`) and that is not a valid
url. No slash is needed between the variable `PYODIDE_CDN_URL` and
`pyodide.js`.
2022-08-31 10:23:38 -07:00
Patrick Arminio f864eee8b5
DOC Fix typo in format_exception example (#3005) 2022-08-23 13:52:37 +09:00
Gyeongjae Choi b4433e1b4a
Do not load unvendored stdlibs by default (#2998)
As discussed in #2940, this PR changes the default value of the fullStdLib flag in loadPyodide to false.
This is a breaking change because for now distutils is not loaded by default.
Also, when fullStdLib is set to true, it loads all unvendored stdlibs except for test.

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2022-08-23 11:52:27 +09:00
Gyeongjae Choi 7231cab3ff
DOC Fix doc warnings (#2898) 2022-07-25 13:30:56 +09:00
Antonio Cuni c54a6dad7e
DOC update the instructions on how to use Node.js (#2856)
[skip ci]
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
2022-07-16 10:33:18 +01:00
lukemarsden 521833b791
DOCS Fix nodefs example in file-system.md (#2867) 2022-07-13 08:53:55 +03:00
Hood Chatham 516364e468
Move more functions into submodules of pyodide (#2790)
This resolves #2689.
2022-06-28 06:31:58 -07:00
Hood Chatham 761b6320ba
Move eval functions to pyodide.code submodule (#2787)
This raises a deprecation warning the first time such a function is used. Work towards #2689.
2022-06-25 21:20:22 -07:00
Hood Chatham cdc59accf3
DOCS Edits and updates (#2756) 2022-06-21 20:15:37 -07:00
Hood Chatham 95b1194945
Enable Wasm BigInt (#2643)
This enables WASM_BIGINT while maintaining (hypothetical) Safari 14 support
by shimming BigInt64Array and BigUint64Array if they are missing. I think the
last time we tried to enable WASM_BIGINT was before #2019 so our chances
are significantly better this time.

This will fix dynamic linking bugs and yields a minor reduction in code size.
2022-06-02 10:09:54 -07:00
Ryan Russell 42d33407ca
DOCS Fix Typos (#2656)
Fixed 2 typos.
2022-05-31 16:06:06 -07:00
Gyeongjae Choi a11f72e145
Simplify the version bump process (#2587) 2022-05-30 10:26:40 +09:00
Ryan Russell 57100ab604
docs(various): Typo fixes (#2641) 2022-05-29 09:45:45 -07:00
Roman Yurchak e2b22a84c3
Add FAQ when micropip fails to find a pure python wheel (#2558)
Closes #2557:
Users keep reporting issues about micropip not finding a pure python wheel
e.g. latest in pyscript/pyscript#297 so it appears the the current message is
not explicit enough.

We should explain in more detail,
* what is happening and why
* what the user can do about it and possibly point them to the issue tracker.
2022-05-17 11:07:36 -07:00
Roman Yurchak 3b74dcbfcf
DOC update FAQ instruction for detecting Emscripten runtime (#2552) 2022-05-13 15:39:50 +09:00
Gyeongjae Choi 410c875e04
DOC Add documentation entry about file system access (#2420)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-05-04 19:43:34 +09:00