Skip to content

Commit 934a7ee

Browse files
hoodmanem-aciek
andauthored
PEP 783: Clarify that PyEmscripten platform is independent of Python (#4863)
And of Python version. Also adjust wording: prefer "Platform" over "ABI" in most places. Co-authored-by: Maciej Olko <maciej.olko@gmail.com>
1 parent 78e1527 commit 934a7ee

1 file changed

Lines changed: 49 additions & 37 deletions

File tree

peps/pep-0783.rst

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ benefit to being able to update the ABI.
7171

7272
In order to balance the ABI stability needs of package maintainers with the ABI
7373
flexibility to allow the platform to move forward, Pyodide plans to adopt a new
74-
ABI for each feature release of Python which we call
74+
Emscripten platform for each feature release of Python which we call
7575
``pyemscripten_${YEAR}_${PATCH}``.
7676

7777
The Pyodide team also coordinates the ABI flags that Pyodide uses with the
@@ -99,44 +99,54 @@ The platform tags will take the form:
9999
Each one of these will be used with a specified Python version. For example, the
100100
platform tag ``pyemscripten_2026_0`` will be used with Python 3.14.
101101

102-
Emscripten Wheel ABI
103-
--------------------
102+
The PyEmscripten Platform
103+
-------------------------
104104

105-
The specification of the ``pyemscripten_<abi>`` platform includes:
105+
The specification of the ``pyemscripten_${YEAR}_${PATCH}`` platform includes:
106106

107107
* Which version of the Emscripten compiler is used
108-
* What libraries are statically linked with the interpreter
108+
* What libraries are statically linked to the application
109109
* What stack unwinding ABI is to be used
110110
* How the loader handles dependency lookup
111111
* That libraries cannot use ``-pthread``
112112
* That libraries should be linked with ``-sWASM_BIGINT``
113113

114-
The ABI is selected by choosing the appropriate version of the Emscripten
115-
compiler and passing appropriate compiler and linker flags. It is possible for
116-
other people to build their own Python interpreter that is compatible with the
117-
Pyodide ABI, it is not necessary to use the Pyodide distribution itself.
114+
The platform is selected by choosing the appropriate version of the Emscripten
115+
compiler and passing appropriate compiler and linker flags.
118116

119-
The Pyodide ABIs are fully specified in the `Pyodide Platform ABI
120-
<https://pyodide.org/en/stable/development/abi.html>`__ documentation.
117+
The platform definition does not include anything about Python and in particular
118+
it is agnostic to the Python version it is intended to be used with. However,
119+
for clarity we will note in the platform documentation which Python version we
120+
plan to use each platform with.
121121

122-
The ``pyodide build`` tool knows how to create wheels that match the Pyodide
123-
ABI. Unlike with manylinux wheels, there is no need for a Docker container to
124-
build the ``pyemscripten_<abi>`` wheels. All that is needed is a Linux machine and
125-
appropriate versions of Python, Node.js, and Emscripten.
122+
The PyEmscripten platforms are fully specified in
123+
`Pyodide's documentation on the PyEmscripten Platform <https://pyodide.org/en/stable/development/abi.html>`__.
126124

127-
It is possible to validate a wheel by installing and importing it into the
125+
To define the platform we need only indicate how the main application is
126+
compiled and linked. This implies how to build a compatible shared library.
127+
However, our documentation includes detailed instructions on how to build a
128+
compatible shared library because we assume most people will be building shared
129+
libraries.
130+
131+
The ``pyodide build`` tool knows how to create wheels that are compatible with the
132+
PyEmscripten platform. Unlike with manylinux wheels, there is no need for a
133+
Docker container to build ``pyemscripten`` wheels. All that is needed is a Linux
134+
machine and appropriate versions of Python, Node.js, and Emscripten.
135+
136+
It is possible to validate that a wheel is compatible with the PyEmscripten
137+
platform by installing and importing it into an appropriate version of the
128138
Pyodide runtime. Because Pyodide can run in an environment with strong
129139
sandboxing guarantees, doing this produces no security risks.
130140

131-
Determining the ABI version
132-
---------------------------
141+
Determining the PyEmscripten Platform Version
142+
---------------------------------------------
133143

134-
The ABI version is stored in the ``PYEMSCRIPTEN_ABI_VERSION`` config variable
135-
and can be determined via:
144+
The PyEmscripten platform version is stored in the
145+
``PYEMSCRIPTEN_PLATFORM_VERSION`` config variable and can be determined via:
136146

137147
.. code-block:: python
138148
139-
pyemscripten_abi_version = sysconfig.get_config_var("PYEMSCRIPTEN_ABI_VERSION")
149+
pyemscripten_platform_version = sysconfig.get_config_var("PYEMSCRIPTEN_PLATFORM_VERSION")
140150
141151
142152
To generate the list of compatible tags, one can use the following code:
@@ -146,9 +156,9 @@ To generate the list of compatible tags, one can use the following code:
146156
from packaging.tags import cpython_tags, _generic_platforms
147157
148158
def _emscripten_platforms() -> Iterator[str]:
149-
pyemscripten_abi_version = sysconfig.get_config_var("PYEMSCRIPTEN_ABI_VERSION")
150-
if pyemscripten_abi_version:
151-
yield f"pyemscripten_{pyemscripten_abi_version}_wasm32"
159+
pyemscripten_platform_version = sysconfig.get_config_var("PYEMSCRIPTEN_PLATFORM_VERSION")
160+
if pyemscripten_platform_version:
161+
yield f"pyemscripten_{pyemscripten_platform_version}_wasm32"
152162
yield from _generic_platforms()
153163
154164
emscripten_tags = cpython_tags(platforms=_emscripten_platforms())
@@ -162,8 +172,8 @@ Package Installers
162172

163173
Installers should use the ``_emscripten_platforms()`` function shown above to
164174
determine which platforms are compatible with an Emscripten build of CPython. In
165-
particular, the ABI version is exposed via
166-
``sysconfig.get_config_var(" PYEMSCRIPTEN_ABI_VERSION")``.
175+
particular, the PyEmscripten platform version is exposed via
176+
``sysconfig.get_config_var("PYEMSCRIPTEN_PLATFORM_VERSION")``.
167177

168178
Package Indexes
169179
---------------
@@ -219,20 +229,21 @@ Alternative Options for the Platform Tag
219229
``pyemscripten`` platform has nothing specifically to do with Python and
220230
indeed can be used by any program that uses the appropriate version of
221231
Emscripten and the appropriate link flags. But
222-
``emscripten_${EMSCRIPTEN_VERSION}`` is too vague by itself because the ABI
232+
``emscripten_${EMSCRIPTEN_VERSION}`` is too vague by itself because the platform
223233
also depends on various linker flags.
224234

225-
There are other communities which have similar problems and would also benefit
226-
from a centralized standard for "Long Term Service" ABIs that the whole
227-
ecosystem could use. However, the Emscripten team have so far not been willing
228-
to provide a this standard since they consider dynamic linking an unusual use
229-
case. Thus it is left for our ecosystem to solve the problem itself. The
230-
platform tag should contains some indication of this.
235+
There are other communities which have similar problems and would also
236+
benefit from a centralized standard for "Long Term Service" Emscripten
237+
platforms that the whole ecosystem could use. However, the Emscripten team
238+
have so far not been willing to provide a this standard since they consider
239+
dynamic linking an unusual use case. Thus it is left for our ecosystem to
240+
solve the problem itself. The platform tag should contain some indication
241+
of this.
231242

232243
``pyemscripten_${PYTHON_MAJOR_MINOR}_${PATCH}``
233244
This would make it clearer which Python version is meant for use with each
234-
ABI, but it leads to conceptual confusion since the platform has nothing to do
235-
with Python.
245+
platform, but it leads to conceptual confusion since the platform has
246+
nothing to do with Python.
236247

237248
``pyodide_...``
238249
For now the platform is defined by Pyodide so this connection would be made
@@ -242,7 +253,7 @@ Alternative Options for the Platform Tag
242253
also more forwards compatible to a future where the definition of the platform
243254
moves upstream of Pyodide.
244255

245-
No ABI patch version
256+
No patch version
246257
We hope never to need the patch version, but it's good to be prepared for
247258
unforseen problems.
248259

@@ -253,7 +264,8 @@ Fo Pyodide Users
253264
----------------
254265
We recommend the `Pyodide documentation on installing packages
255266
<https://pyodide.org/en/stable/usage/loading-packages.html>`__. We will make a
256-
table showing which ``pyemscripten`` ABI each Pyodide version is compatible with.
267+
table showing which ``pyemscripten`` platform version each Pyodide version is
268+
compatible with.
257269

258270
For Package Maintainers
259271
-----------------------

0 commit comments

Comments
 (0)