-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-95451: Update docs for wasm32-emscripten and -wasi platforms #95452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ea28ffb
a2b3ed3
48991b0
948f519
d9a2457
6fee2e2
2bebb1b
c7db243
b9e04e7
c0061fd
1d5d890
47b16f8
1bf424a
61192a0
a16f568
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.. include for modules that don't work on WASM | ||
|
||
.. availability:: not Emscripten, not WASI. | ||
|
||
This module does not work or is not available on WebAssembly platforms | ||
``wasm32-emscripten`` and ``wasm32-wasi``. See | ||
:ref:`wasm-availability` for more information. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,8 @@ | |
This module provides the basic infrastructure for writing asynchronous socket | ||
service clients and servers. | ||
|
||
.. include:: ../includes/wasm-notavail.rst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise, this module is scheduled for removal in 3.12 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the notes added are useful for 3.11, or at least harmless! |
||
|
||
There are only two ways to have a program on a single processor do "more than | ||
one thing at a time." Multi-threaded programming is the simplest and most | ||
popular way to do it, but there is another very different technique, that lets | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ this module. | |
|
||
.. availability:: Unix, not VxWorks. | ||
|
||
.. include:: ../includes/wasm-notavail.rst | ||
|
||
Comment on lines
39
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not super important because this is a deprecated module with removal scheduled in 3.13, but this does lead to a duplicated |
||
Hashing Methods | ||
--------------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ when creating a virtual environment) or after explicitly uninstalling | |
:pep:`453`: Explicit bootstrapping of pip in Python installations | ||
The original rationale and specification for this module. | ||
|
||
.. include:: ../includes/wasm-notavail.rst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have a super strong feeling here, but maybe better to put the availability note right above the |
||
|
||
Command line interface | ||
---------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ interface to the :c:func:`fcntl` and :c:func:`ioctl` Unix routines. For a | |
complete description of these calls, see :manpage:`fcntl(2)` and | ||
:manpage:`ioctl(2)` Unix manual pages. | ||
|
||
.. include:: ../includes/wasm-notavail.rst | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be better to put this after the introduction prose and right above the " There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it is fine to have a short paragraph to introduce the module, then the availability note. |
||
|
||
All functions in this module take a file descriptor *fd* as their first | ||
argument. This can be an integer file descriptor, such as returned by | ||
``sys.stdin.fileno()``, or an :class:`io.IOBase` object, such as ``sys.stdin`` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,58 @@ Notes on availability | |
libc version, then both conditions must hold. For example a feature with note | ||
*Availability: Linux >= 3.17 with glibc >= 2.27* requires both Linux 3.17 or | ||
newer and glibc 2.27 or newer. | ||
|
||
.. _wasm-availability: | ||
|
||
WebAssembly platforms | ||
--------------------- | ||
|
||
The `WebAssembly`_ platforms ``wasm32-emscripten`` (`Emscripten`_) and | ||
``wasm32-wasi`` (`WASI`_) provide a subset of POSIX APIs. WebAssembly runtimes | ||
and browsers are sandboxed and have limited access to the host and external | ||
resources. Any Python standard library module that uses processes, threading, | ||
networking, signals, or other forms of inter-process communication (IPC), is | ||
either not available or may not work as on other Unix-like systems. File I/O, | ||
file system, and Unix permission-related functions are restricted, too. | ||
Emscripten does not permit blocking I/O. Other blocking operations like | ||
:func:`~time.sleep` block the browser event loop. | ||
|
||
The properties and behavior of Python on WebAssembly platforms depend on the | ||
`Emscripten`_-SDK or `WASI`_-SDK version, WASM runtimes (browser, NodeJS, | ||
`wasmtime`_), and Python build time flags. WebAssembly, Emscripten, and WASI | ||
are evolving standards; some features like networking may be | ||
supported in the future. | ||
|
||
For Python in the browser, users should consider `Pyodide`_ or `PyScript`_. | ||
PyScript is built on top of Pyodide, which itself is built on top of | ||
CPython and Emscripten. Pyodide provides access to browsers' JavaScript and | ||
DOM APIs as well as limited networking capabilities with JavaScript's | ||
``XMLHttpRequest`` and ``Fetch`` APIs. | ||
|
||
* Process-related APIs are not available or always fail with an error. That | ||
includes APIs that spawn new processes (:func:`~os.fork`, | ||
:func:`~os.execve`), wait for processes (:func:`~os.waitpid`), send signals | ||
(:func:`~os.kill`), or otherwise interact with processes. The | ||
:mod:`subprocess` is importable but does not work. | ||
|
||
* The :mod:`socket` module is available, but is limited and behaves | ||
differently from other platforms. On Emscripten, sockets are always | ||
non-blocking and require additional JavaScript code and helpers on the | ||
server to proxy TCP through WebSockets; see `Emscripten Networking`_ | ||
for more information. WASI snapshot preview 1 only permits sockets from an | ||
existing file descriptor. | ||
|
||
* Some functions are stubs that either don't do anything and always return | ||
hardcoded values. | ||
Comment on lines
+108
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to refer to, e.g., the |
||
|
||
* Functions related to file descriptors, file permissions, file ownership, and | ||
links are limited and don't support some operations. For example, WASI does | ||
not permit symlinks with absolute file names. | ||
|
||
.. _WebAssembly: https://webassembly.org/ | ||
.. _Emscripten: https://emscripten.org/ | ||
.. _Emscripten Networking: https://emscripten.org/docs/porting/networking.html> | ||
.. _WASI: https://wasi.dev/ | ||
.. _wasmtime: https://wasmtime.dev/ | ||
.. _Pyodide: https://pyodide.org/ | ||
.. _PyScript: https://pyscript.net/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
|
||
-------------- | ||
|
||
.. include:: ../includes/wasm-notavail.rst | ||
|
||
Introduction | ||
------------ | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.