Skip to content

Commit b1a156a

Browse files
PEP 816: WASI Support (#4732)
Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent d34b798 commit b1a156a

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,10 @@ peps/pep-0808.rst @FFY00
687687
peps/pep-0809.rst @zooba
688688
peps/pep-0810.rst @pablogsal @DinoV @Yhg1s
689689
peps/pep-0811.rst @sethmlarson @gpshead
690+
# ...
690691
peps/pep-0814.rst @vstinner @corona10
691692
peps/pep-0815.rst @emmatyping
693+
peps/pep-0816.rst @brettcannon
692694
# ...
693695
peps/pep-2026.rst @hugovk
694696
# ...

peps/pep-0816.rst

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
PEP: 816
2+
Title: WASI Support
3+
Author: Brett Cannon <[email protected]>
4+
Discussions-To: Pending
5+
Status: Draft
6+
Type: Informational
7+
Created: 05-Nov-2025
8+
Post-History: Pending
9+
10+
11+
Abstract
12+
========
13+
14+
This PEP outlines the expected support for WASI_ by CPython. It contains enough
15+
details to know what WASI and WASI SDK version is expected to be supported for
16+
any release of CPython while official WASI support is specified in :pep:`11`.
17+
18+
19+
Motivation
20+
==========
21+
22+
CPython has supported WASI according to :pep:`11` since Python 3.11. As part of
23+
this support, CPython needs to target two different things: the WASI_ version
24+
and the `WASI SDK`_ version (both of whose development is driven by the
25+
`Bytecode Alliance`_). The former is the specification of WASI itself while the
26+
latter is a version of clang_ with a specific version of wasi-libc_ as the
27+
sysroot that allows for compiling CPython to WASI. There is roughly an annual
28+
release cadence for new WASI versions while there's no set release cadence for
29+
WASI SDK.
30+
31+
Agreeing on which WASI and WASI SDK versions to support allows for clear
32+
targeting of the CPython code base towards those versions. This also lets the
33+
community set appropriate expectations as to what will (not) be considered a
34+
bug if it only manifests itself under a certain WASI or WASI SDK version. It
35+
also provides the community an overall target for WASI and WASI SDK for any
36+
specific Python version when building other software like libraries. This is
37+
important as WASI SDK is NOT forwards- or backwards-compatible due to the ABI
38+
of wasi-libc not making any compatibility guarantees, making broad coordination
39+
important so code works together.
40+
41+
This coordination and recording around version targets can be important in
42+
situations where the selected version is non-obvious. For example, WASI SDK 26
43+
and 27 have a `bug <https://github.com/WebAssembly/wasi-libc/issues/617>`__
44+
which cause CPython to hang in certain situations (including exiting the REPL).
45+
Because the bug is in thread support code it wouldn't necessarily be obvious to
46+
others in the community that CPython will not target those versions and thus
47+
3rd-party code should also avoid those versions.
48+
49+
50+
Rationale
51+
=========
52+
53+
While technically separate, CPython cannot support a version of WASI until WASI
54+
SDK supports it. WASI versions are considered backwards-compatible with each
55+
other, but WASI SDK is NOT compatible forwards or backwards thanks to wasi-libc
56+
not having ABI compatibility guarantees. As such, it's important to set support
57+
expectations for a specific WASI SDK version in CPython. Historically, the
58+
support difference between WASI SDK versions for CPython have involved settings
59+
in the ``config.site`` file that is maintained for WASI. Support issues have
60+
come up due to bugs in WASI SDK itself. Finally, new features being supported
61+
by WASI SDK can also cause code that wasn't previously used in a WASI build to
62+
suddenly be run which can require code updates to pass tests.
63+
64+
As for WASI version support, that typically translates into what stdlib modules
65+
are (potentially) usable with a WASI build. For example, WASI 0.2 added socket
66+
support and WASI 0.3.1 is scheduled to have some form of threading support.
67+
Knowing what WASI version is supported sets expectations for what stdlib
68+
modules should be supported.
69+
70+
Interpreter feature availability can be dependent on the WASI version. For
71+
instance, until there is threading support there can't be free-threading
72+
support in WASI. Once again, this helps set expectations of what should be
73+
working based on the target WASI version.
74+
75+
76+
Specification
77+
=============
78+
79+
The WASI and WASI SDK version supported by a CPython version in CI or its
80+
stable Buildbot builder when b1 is released MUST be the version to be supported
81+
for the lifetime of that Python version after this PEP is accepted. If there is
82+
a discrepancy between CI and the Buildbot builder for some reason, the WASI
83+
maintainers as specified by :pep:`11` will choose which sets of versions will
84+
be designated as the versions to support.
85+
86+
The WASI version and WASI SDK version supported for a Python version MUST be
87+
recorded in :pep:`11` as an official record.
88+
89+
If for some reason a supported WASI SDK version needs to change after being
90+
recorded, a note will be made in :pep:`11` as to when and why the change was
91+
made. Such a change is at the discretion of the maintainers of WASI support as
92+
listed in :pep:`11` and does not require steering council approval. The
93+
expectation, though, is that such a change SHOULD NOT occur.
94+
95+
Changing the WASI version after it has been recorded MUST NOT occur UNLESS the
96+
steering council approves it. This is due to the increased support burden for
97+
new WASI versions and the shift in expectations of what CPython would support
98+
when support expectations have already been set.
99+
100+
Any updates to :pep:`11` to reflect the appropriate WASI version for the target
101+
triple for the main branch MUST be made as needed, but it does NOT require
102+
steering council approval to update. The steering council is spared needing to
103+
approve such an update as it does not constitute a new platform and is more in
104+
line with a new OS release which currently does not require steering council
105+
approval.
106+
107+
108+
Designated Support
109+
==================
110+
111+
Note that while WASI SDK in some places lists both a major and minor version,
112+
in actuality the minor version has never been set to anything other than ``0``
113+
and there's an expectation that
114+
`any minor version will be ABI compatible with the overall major version <https://bytecodealliance.zulipchat.com/#narrow/channel/219900-wasi/topic/Platform.20tags.20for.20packages.20targeting.20WASI/near/516771862>`__.
115+
As well, the WASI community only refers to WASI SDK versions by their major
116+
version due to there having never been a minor release. Subsequently, this PEP
117+
only records the major version of WASI SDK until such time that there's a need
118+
to record a minor version.
119+
120+
====== ==== ========
121+
Python WASI WASI SDK
122+
====== ==== ========
123+
3.14 0.1 24
124+
3.13 0.1 24
125+
3.12 0.1 16
126+
3.11 0.1 16
127+
====== ==== ========
128+
129+
130+
Notes
131+
-----
132+
133+
All versions prior to Python 3.15 predate this PEP. The version support for
134+
those versions is based on what was supported when this PEP was written.
135+
136+
WASI was a tier 3 platform according to :pep:`11` for Python 3.11 and 3.12.
137+
WASI became a tier 2 platform starting with Python 3.13.
138+
139+
WASI 0.2 support has been skipped due to lack of time, to the point that it was
140+
deemed better to go straight to WASI 0.3 instead. This is based on a
141+
recommendation from the `Bytecode Alliance`_.
142+
143+
WASI SDK 26 and 27 have a
144+
`bug <https://github.com/WebAssembly/wasi-libc/issues/617>`__ which causes
145+
CPython to hang in certain situations, and so they have been skipped.
146+
147+
148+
Acknowledgements
149+
================
150+
151+
Thanks to Joel Dice and Ben Brandt of the Python
152+
`sub-group <https://github.com/bytecodealliance/SIG-Guest-Languages/blob/main/docs/subgroups.md>`__
153+
of the
154+
`guest languages SIG <https://github.com/bytecodealliance/SIG-Guest-Languages>`__
155+
of the `Bytecode Alliance`_ for discussing the specification of this PEP.
156+
157+
158+
Footnotes
159+
=========
160+
161+
.. _WASI: https://wasi.dev
162+
.. _WASI SDK: https://github.com/WebAssembly/wasi-sdk
163+
.. _wasi-libc: https://github.com/WebAssembly/wasi-libc
164+
.. _clang: https://clang.llvm.org
165+
.. _Bytecode Alliance: https://bytecodealliance.org
166+
167+
168+
Copyright
169+
=========
170+
171+
This document is placed in the public domain or under the
172+
CC0-1.0-Universal license, whichever is more permissive.

0 commit comments

Comments
 (0)