@@ -652,21 +652,43 @@ packages like aiohttp, Requests, Pydantic, cryptography, and orjson.
652
652
About 60 packages are also testing against Pyodide in their CI, including NumPy,
653
653
pandas, awkward-cpp, scikit-image, statsmodels, PyArrow, Hypothesis, and PyO3.
654
654
655
- Emscripten Wheel Format
656
- ~~~~~~~~~~~~~~~~~~~~~~~
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::
657
675
658
- Emscripten wheels will use either the format ``emscripten_<version>_wasm32 `` or
659
- ``pyodide_<abi>_wasm32 ``. For example:
660
676
661
- * ``emscripten_3_1_58_wasm32 ``
662
- * ``pyodide_2025_0_wasm32 ``
677
+ from packaging.tags import cpython_tags, _generic_platforms
663
678
664
- The first triple is ambiguous, since even with Emscripten 3.1.58 it is possible
665
- to link dynamic libraries that require a large number of distinct ABIs,
666
- depending on linker and compiler options. It is our intent that the
667
- ``pyodide_2025_0 `` specifies the particular ABI. Thus, the relationship between
668
- ``pyodide_<abi> `` and ``emscripten_<version> `` is intended to be the same as the
669
- relationship between ``manylinux<version> `` and ``linux ``.
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
+ ~~~~~~~~~~~~~~~~~~~~
670
692
671
693
The specification of the ``pyodide_<abi> `` ABI includes:
672
694
@@ -682,16 +704,45 @@ compiler and passing appropriate compiler and linker flags. It is possible for
682
704
other people to build their own Python interpreter that is compatible with the
683
705
Pyodide ABI, it is not necessary to use the Pyodide distribution itself.
684
706
685
- The ``pyodide build `` tool knows how to create wheels that match our ABI. As an
686
- alternative,
687
- `the auditwheel-emscripten tool <https://github.com/ryanking13/auditwheel-emscripten >`__
688
- is capable of performing basic compatibility checks, vendoring shared libraries,
689
- and retagging the wheel from ``emscripten_<version> `` to ``pyodide_<abi> ``. Unlike
690
- with manylinux, there is no need for a Docker container to build the
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
691
709
``pyodide_<abi> `` wheels. All that is needed is a Linux machine and appropriate
692
710
versions of Python, Node.js, and Emscripten.
693
711
694
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
+
745
+
695
746
PEP 11
696
747
------
697
748
@@ -786,7 +837,8 @@ partially-upstreamed features so that Pyodide can replace them with more
786
837
complete versions downstream.
787
838
788
839
These backwards compatibility concerns impact not just the runtime but also the
789
- packaging system.
840
+ packaging system. Adding new platform tags should not affect existing packaging
841
+ tools because tools ignore wheels with an unknown package tag.
790
842
791
843
792
844
Security Implications
@@ -809,8 +861,11 @@ to use them all at runtime. The documentation will cover this in a similar form
809
861
to the existing Windows embeddable package. In the short term, we will encourage
810
862
developers to use Pyodide if at all possible.
811
863
812
- Second, developers of packages with binary components need to know how to build
813
- and release them for Emscripten (see Packaging).
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.
814
869
815
870
816
871
Reference Implementation
0 commit comments