@@ -5,7 +5,6 @@ Sponsor: Łukasz Langa <lukasz at python.org>
55Discussions-To: https://discuss.python.org/t/84996
66Status: Draft
77Type: Standards Track
8- Topic: Packaging
98Created: 18-Mar-2025
109Python-Version: 3.14
1110Post-History: `18-Mar-2025 <https://discuss.python.org/t/84996 >`__
@@ -20,8 +19,17 @@ also maintains an Emscripten target.
2019
2120This PEP formalizes the addition of Tier 3 for Emscripten support in Python 3.14
2221which `was approved by the Steering Council on October 25, 2024
23- <https://github.com/python/steering-council/issues/256> `__. The goal is to allow
24- Pyodide wheels to be uploaded to PyPI.
22+ <https://github.com/python/steering-council/issues/256> `__. The goals are:
23+
24+ 1. To describe the current state of the CPython Emscripten runtime
25+ 2. To describe the current state of the Pyodide runtime
26+ 3. To identify minor features to be upstreamed from the Pyodide runtime into the
27+ CPython Emscripten runtime
28+
29+ The minor features identified here are all features that could be implemented
30+ without a PEP. We discuss more significant runtime features that we would like
31+ to implement but we defer decisions on those features to subsequent PEPs.
32+
2533
2634Motivation
2735==========
@@ -41,33 +49,6 @@ Emscripten platform.
4149Emscripten and WASI are also the only supported platforms that offer any
4250meaningful sandboxing.
4351
44- Goals
45- =====
46-
47- It is our long term goal to upstream the entire Pyodide runtime into CPython,
48- but this is out of scope for the present PEP. This PEP only attempts to
49- establish the foundation for future work.
50-
51- Runtime Goals
52- -------------
53-
54- 1. To describe the current state of the CPython Emscripten runtime
55- 2. To describe the current state of the Pyodide runtime
56- 3. To identify minor features to be upstreamed from the Pyodide runtime into the
57- CPython Emscripten runtime
58-
59- The minor features identified here are all features that could be implemented
60- without a PEP. We discuss more significant runtime features that we would like
61- to implement but we defer decisions on those features to subsequent PEPs.
62-
63- Packaging Goals
64- ---------------
65-
66- 1. To describe Pyodide's packaging tooling
67- 2. To describe Pyodide's wheel abi to a similar level of detail as the manylinux
68- PEPs
69- 3. For Pyodide wheels to be allowed for upload to PyPI
70-
7152
7253Emscripten Platform Information
7354===============================
@@ -520,7 +501,7 @@ The following modules can be imported, but are not functional:
520501as well as any functionality that requires these.
521502
522503The following are present but cannot be imported due to a dependency on the
523- termios package which has been removed:
504+ termios module which has been removed:
524505
525506- pty
526507- tty
@@ -638,110 +619,6 @@ buildbots, maintained by Russell Keith-Magee.
638619CPython does not currently test Tier 3 platforms on GitHub Actions, but if this
639620ever changes, their Linux runners are able to build and test Emscripten Python.
640621
641- Packaging
642- ---------
643-
644- Existing Package Support
645- ~~~~~~~~~~~~~~~~~~~~~~~~
646-
647- Pyodide currently maintains ports of 255 different packages at the time of this
648- writing, including major scientific Python packages like NumPy, SciPy, pandas,
649- Polars, scikit-learn, OpenCV, PyArrow, and Pillow as well as general purpose
650- packages like aiohttp, Requests, Pydantic, cryptography, and orjson.
651-
652- About 60 packages are also testing against Pyodide in their CI, including NumPy,
653- pandas, awkward-cpp, scikit-image, statsmodels, PyArrow, Hypothesis, and PyO3.
654-
655- Pyodide Wheel Tags
656- ~~~~~~~~~~~~~~~~~~
657-
658- Pyodide wheels will use ``pyodide_<abi>_wasm32 `` as the platform tag. For
659- example, ``pyodide_2025_0_wasm32 ``.
660-
661- With a fixed version of Emscripten, it is possible to link dynamic libraries
662- that require a large number of distinct ABIs, depending on ABI-sensitive linker
663- options and what versions of what static libraries are linked. It is our intent
664- that the ``pyodide_2025_0 `` specifies the particular ABI that will work with the
665- Pyodide CPython runtime.
666-
667- For example, wheels with the following tags are compatible with Python 3.13
668- Pyodide:
669-
670- - ``cp13-cp13-pyodide_2025_0_wasm32 ``
671- - ``abi3-cp10-pyodide_2025_0_wasm32 ``
672-
673- As well as all non-platformed tags. To generate the list of compatible tags, one
674- can use the following code::
675-
676-
677- from packaging.tags import cpython_tags, _generic_platforms
678-
679- def _emscripten_platforms() -> Iterator[str]:
680- pyodide_abi_version = sysconfig.get_config_var("PYODIDE_ABI_VERSION")
681- if pyodide_abi_version:
682- yield f"pyodide_{pyodide_abi_version}_wasm32"
683- yield from _generic_platforms()
684-
685- emscripten_tags = cpython_tags(platforms=_emscripten_platforms())
686-
687- This code will be added to `pypa/packaging
688- <https://github.com/pypa/packaging/pull/804> `__.
689-
690- Emscripten Wheel ABI
691- ~~~~~~~~~~~~~~~~~~~~
692-
693- The specification of the ``pyodide_<abi> `` ABI includes:
694-
695- * Which version of the Emscripten compiler is used
696- * What libraries are statically linked with the interpreter
697- * What stack unwinding ABI is to be used
698- * Which runtime platform features are required to be present
699-
700- and a handful of other similar details that affect the ABI.
701-
702- The ABI is selected by choosing the appropriate version of the Emscripten
703- compiler and passing appropriate compiler and linker flags. It is possible for
704- other people to build their own Python interpreter that is compatible with the
705- Pyodide ABI, it is not necessary to use the Pyodide distribution itself.
706-
707- The ``pyodide build `` tool knows how to create wheels that match our ABI. Unlike
708- with manylinux wheels, there is no need for a Docker container to build the
709- ``pyodide_<abi> `` wheels. All that is needed is a Linux machine and appropriate
710- versions of Python, Node.js, and Emscripten.
711-
712-
713- Package Installers
714- ~~~~~~~~~~~~~~~~~~
715-
716- Installers should use the ``_emscripten_platforms() `` function shown above to
717- determine which platforms are compatible with an Emscripten build of CPython. In
718- particular, the Pyodide ABI version is exposed via
719- ``sysconfig.get_config_var("PYODIDE_ABI_VERSION") ``.
720-
721-
722- Package indexes
723- ~~~~~~~~~~~~~~~
724-
725- We recommend that package indexes accept any wheel whose platform tag matches
726- ``pyodide_[0-9]+_[0-9]+_wasm32 ``. We recommend that package indexes continue not
727- accepting wheels that match ``emscripten_[0-9]+_[0-9]+_[0-9]+_wasm32 ``.
728-
729-
730- Dependency Specifier Markers
731- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
732-
733- To check for the Emscripten platform in a dependency specifier, one can use
734- ``sys_platform == 'emscripten' `` (or its negation). Such checks are already in use
735- in the wild and seem to be sufficient for the needs of the community.
736-
737-
738- Trove Classifier
739- ~~~~~~~~~~~~~~~~
740-
741- Packages that build and test Emscripten wheels can declare this by adding the
742- ``Environment :: WebAssembly :: Emscripten ``. PyPI already accepts uploads of
743- packages with this classifier.
744-
745622
746623PEP 11
747624------
@@ -836,10 +713,6 @@ care to minimize backwards incompatibility. We will also need a way to disable
836713partially-upstreamed features so that Pyodide can replace them with more
837714complete versions downstream.
838715
839- These backwards compatibility concerns impact not just the runtime but also the
840- packaging system. Adding new platform tags should not affect existing packaging
841- tools because tools ignore wheels with an unknown package tag.
842-
843716
844717Security Implications
845718=====================
@@ -861,12 +734,6 @@ to use them all at runtime. The documentation will cover this in a similar form
861734to the existing Windows embeddable package. In the short term, we will encourage
862735developers to use Pyodide if at all possible.
863736
864- Second, maintainers of packages with binary components need to know how to
865- build, test, label, and deploy them for Emscripten (see Packaging). The Pyodide
866- documentation on `building and testing packages
867- <https://pyodide.org/en/stable/development/building-and-testing-packages.html> `__
868- is the best reference for this.
869-
870737
871738Reference Implementation
872739========================
0 commit comments