Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 72 additions & 7 deletions peps/pep-0776.rst
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,11 @@ packages like aiohttp, Requests, Pydantic, cryptography, and orjson.
About 60 packages are also testing against Pyodide in their CI, including NumPy,
pandas, awkward-cpp, scikit-image, statsmodels, PyArrow, Hypothesis, and PyO3.

Emscripten Wheel Format
~~~~~~~~~~~~~~~~~~~~~~~
Emscripten Wheel Tags
~~~~~~~~~~~~~~~~~~~~~

Emscripten wheels will use either the format ``emscripten_<version>_wasm32`` or
``pyodide_<abi>_wasm32``. For example:
Emscripten wheels will use as the platform tag either
``emscripten_<version>_wasm32`` or ``pyodide_<abi>_wasm32``. For example:

* ``emscripten_3_1_58_wasm32``
* ``pyodide_2025_0_wasm32``
Expand All @@ -651,6 +651,34 @@ depending on linker and compiler options. It is our intent that the
``pyodide_<abi>`` and ``emscripten_<version>`` is intended to be the same as the
relationship between ``manylinux<version>`` and ``linux``.

For example, wheels with the following tags are compatible with Python 3.13
Pyodide:

- ``cp13-cp13-emscripten_3_1_58_wasm32``
- ``cp13-cp13-pyodide_2025_0_wasm32``
- ``abi3-cp10-pyodide_2025_0_wasm32``

As well as all non platformed tags. To generate the list of compatible tags, one
Comment thread
hoodmane marked this conversation as resolved.
Outdated
can use the following code:
Comment thread
hoodmane marked this conversation as resolved.
Outdated

.. code-block:: Python
Comment thread
hoodmane marked this conversation as resolved.
Outdated

from packaging.tags import cpython_tags, _generic_platforms

def _emscripten_platforms() -> Iterator[str]:
pyodide_abi_version = sysconfig.get_config_var("PYODIDE_ABI_VERSION")
if pyodide_abi_version:
yield f"pyodide_{pyodide_abi_version}_wasm32"
yield from _generic_platforms()

emscripten_tags = cpython_tags(platforms=_emscripten_platforms())

`This code will be added to pypa/packaging
<https://github.com/pypa/packaging/pull/804>`__.
Comment thread
hoodmane marked this conversation as resolved.
Outdated

Emscripten Wheel ABI
~~~~~~~~~~~~~~~~~~~~

The specification of the ``pyodide_<abi>`` ABI includes:

* Which version of the Emscripten compiler is used
Expand All @@ -675,6 +703,39 @@ with manylinux, there is no need for a Docker container to build the
versions of Python, Node.js, and Emscripten.


Package Installers
~~~~~~~~~~~~~~~~~~

Installers should use the ``_emscripten_platforms()`` function shown above to
determine which platforms are compatible with an Emscripten build of CPython. In
particular, the Pyodide ABI version is exposed via
``sysconfig.get_config_var("PYODIDE_ABI_VERSION")``.


Package indexes
~~~~~~~~~~~~~~~

We recommend that package indexes accept any wheel whose platform tag matches
``pyodide_[0-9]+_[0-9]+_wasm32``. We recommend that package indexes continue not
accepting wheels that match ``emscripten_[0-9]+_[0-9]+_[0-9]+_wasm32``.
Comment thread
hoodmane marked this conversation as resolved.


Dependency Specifier Markers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To check for the Emscripten platform in a dependency specifier, one can use
``sys_platform == 'emscripten'`` (or its negation). Such checks are already in use
in the wild and seem to be sufficient for the needs of the community.


Trove Classifier
~~~~~~~~~~~~~~~~

Packages that build and test Emscripten wheels can declare this by adding the
``Environment :: WebAssembly :: Emscripten``. PyPI already accepts uploads of
packages with this classifier.


PEP 11
------

Expand Down Expand Up @@ -767,7 +828,8 @@ partially-upstreamed features so that Pyodide can replace them with more
complete versions downstream.

These backwards compatibility concerns impact not just the runtime but also the
packaging system.
packaging system. Adding new platform tags should not affect existing packaging
tools because tools ignore wheels with an unknown package tag.


Security Implications
Expand All @@ -790,8 +852,11 @@ to use them all at runtime. The documentation will cover this in a similar form
to the existing Windows embeddable package. In the short term, we will encourage
developers to use Pyodide if at all possible.

Second, developers of packages with binary components need to know how to build
and release them for Emscripten (see Packaging).
Second, maintainers of packages with binary components need to know how to
build, test, label, and deploy them for Emscripten (see Packaging). The Pyodide
documentation on `building and testing packages
<https://pyodide.org/en/stable/development/building-and-testing-packages.html>`__
is the best reference for this.


Reference Implementation
Expand Down