# Important links
- [`os-wasi` label](https://github.com/python/cpython/labels/OS-wasi)
- [WASI dev container definition](https://github.com/python/cpython-devcontainers/tree/main/wasicontainer) ([image](https://github.com/python/cpython-devcontainers/pkgs/container/wasicontainer))
- Buildbot [[builders](https://buildbot.python.org/#/builders?tags=%2Bwasi)ers](https://buildbot.python.org/#/builders?tags=%2Bwasi)
# Legend
- π₯§ beginner-friendly ("as easy as pie")
- π Working on it (bookmark where I/someone left off)
- π Blocked by something (stop and check status before proceeding)
# Plans
- [ ] [Write down support](https://peps.python.org/pep-0816/#:~:text=The%20WASI%20version%20and%20WASI%20SDK%20version%20supported%20for%20a%20Python%20version%20MUST%20be%20recorded%20in%20PEP%2011%20as%20an%20official%20record.) for Python 3.15 as outlined in [PEP 816](https://peps.python.org/pep-0816/)
- [ ] π [Support `wasm32-wasip3`](https://github.com/python/cpython/issues/121634) (skipping p2; blocked on WASI 0.3 being released)
- [x] Ability to specify host triple
- [x] Find out if `wasip2` is compatible w/ preview1 hosts
- [ ] buildbot
- [ ] PEP 11
- [ ] PEP for a wheel tag ([discussion](https://bytecodealliance.zulipchat.com/#narrow/channel/219900-wasi/topic/Platform.20tags.20for.20packages.20targeting.20WASI/with/516694780))
- [ ] Expose WASI details in `sys` or `platform` ([changes in wasi-libc](https://github.com/WebAssembly/wasi-libc/issues/688))
- [ ] Draft PEP (thanks to PEP 816, might be able to do just `wasi_wasm32` and non-standard `wasi_N_N_sdk_N_wasm32` in `packaging` when not matching PEP 11)
- [ ] Post to DPO
- [ ] Submit for approval
- [ ] `wasi package`
- [x] Figure out file name (`python-3.25.0a3-wasm32-wasip1.tar.xz`; host triple from `config.toml`; [`platform.python_version()`](https://docs.python.org/3/library/platform.html#platform.python_version))
- [x] Research what should be shipped for building extensions
- `--without-static-libpython`
- Top-level stuff in `cross-build/wasm32-wasip1` accounted for (e.g. [`pyconfig.h`](https://github.com/python/cpython/blob/957f9fe162398fceeaa9ddba8b40046b8a03176d/Makefile.pre.in#L2964))
- [`build/lib.*` to the stdlib (sans `__pycache__`)](https://github.com/python/cpython/blob/957f9fe162398fceeaa9ddba8b40046b8a03176d/Makefile.pre.in#L2853-L2855)
- [`LICENSE` to `LICENSE.txt`](https://github.com/python/cpython/blob/957f9fe162398fceeaa9ddba8b40046b8a03176d/Makefile.pre.in#L2856)
- `include/pythonN.Nd` if debug, otherwise `lib/pythonN.N`
- `python.wasm` renamed to `python3.NN.wasm` (although where to put it since it isn't a self-contained binary?)
- Try to be generic so it works for any Python build so it can be used to compare against `make install` as well as be used for relocatable builds
- [X] [Refactor](https://github.com/brettcannon/cpython/tree/wasi-refactor) `Platforms/WASI` to support other subcommands ([PR](https://github.com/python/cpython/pull/145404))
- [ ] Implement
- [ ] All defaults
- [ ] Specify the directory/file path
- [ ] Specify build directory
- [ ] Flag to allow for building if not done, else error out
- [ ] Make [reproducible](https://sethmlarson.dev/security-developer-in-residence-weekly-report-14)
- [ ] Provide some test script to compare what gets packaged against an install to some directory
- [ ] Use the WASI dev container to [build and export the package](https://docs.docker.com/build/building/export/)
- [ ] Have the RM release the binaries
- [ ] [External dependencies](https://github.com/python/cpython-source-deps) via `wasi externals`
- [ ] Figure out what version policy we want (i.e. always latest or freeze versions like Windows builds? If latter, make it an external config)
- [ ] [zlib](https://github.com/python/cpython/issues/91246) (and potentially undoing part of https://github.com/python/cpython/pull/130297)/zlib-ng
- `RANLIB=/opt/wasi-sdk-29.0-x86_64-linux/bin/ranlib CC=/opt/wasi-sdk-29.0-x86_64-linux/bin/clang CHOST=wasm32 ./configure --static --zlib-compat --prefix ... && make install`
- Blank out `PKG_CONFIG_SYSROOT_DIR` and `PKG_CONFIG_PATH`, set `PKG_CONFIG_LIBDIR` to where `lib/pkgconfig` ended up from `--prefix`
- [ ] bzip2
- [ ] xz
- [`get_externals.bat`](https://github.com/python/cpython/blob/5592399313c963c110280a7c98de974889e1d353/PCbuild/get_externals.bat#L61)
- [`python.props`](https://github.com/python/cpython/blob/5592399313c963c110280a7c98de974889e1d353/PCbuild/python.props#L73)
- [`externals.spdx.json`](https://github.com/python/cpython/blob/5592399313c963c110280a7c98de974889e1d353/Misc/externals.spdx.json#L160)
- [ ] sqlite
- [ ] zstd
- [ ] mpdecimal
- [x] OpenSSL (not safe as WebAssembly doesn't have constant time ops)
- [ ] π Networking under WASI 0.3 (blocked on threading in WASI 0.3 being released)
- [Joel's hack](https://github.com/dicej/cpython/commit/118e9d8eeabb6345d57295f6cec1616694eacbc2)
- Any tests requiring threads probably won't work
- See the [headers in wasi-libc](https://github.com/WebAssembly/wasi-libc/tree/main/libc-top-half/musl/include) for what can be turned on
- Will probably require tweaking `config.site`
- [ ] π₯§ Make sure build details are still relevant
- [ ] Check if all the flags set in `configure.ac` are necessary
- [ ] Check what `__wasi__` usage can be removed
- [x] [Check](https://github.com/python/cpython/issues/115982) that the [site config](https://github.com/python/cpython/blob/main/Tools/wasm/config.site-wasm32-wasi) is up-to-date
- [ ] [[HTTP fetch API]]
# Packaging notes
```shell
./configure --without-static-libpython --prefix (pwd)/builddir && make -s -j && make install
```
## Release
```shell
β² ls
π bin π include π lib π share
```
```shell
β² ls bin/
π idle3 π idle3.15 π pip3 π pip3.15 π pydoc3 π pydoc3.15 π python3 π python3-config π python3.15 π python3.15-config
```
```shell
β² ls include/python3.15/
π abstract.h π codecs.h π dictobject.h π floatobject.h π listobject.h π object.h π py_curses.h π pyexpat.h π pymem.h π pythonrun.h π structmember.h π warnings.h
π audit.h π compile.h π dynamic_annotations.h π frameobject.h π longobject.h π objimpl.h π pyatomic.h π pyframe.h π pyport.h π pythread.h π structseq.h π weakrefobject.h
π bltinmodule.h π complexobject.h π enumobject.h π genericaliasobject.h π marshal.h π opcode.h π pybuffer.h π pyhash.h π pystate.h π pytypedefs.h π sysmodule.h
π boolobject.h π cpython π errcode.h π import.h π memoryobject.h π opcode_ids.h π pycapsule.h π pylifecycle.h π pystats.h π rangeobject.h π traceback.h
π bytearrayobject.h π critical_section.h π exports.h π internal π methodobject.h π osdefs.h π pyconfig.h π pymacconfig.h π pystrcmp.h π refcount.h π tupleobject.h
π bytesobject.h π datetime.h π fileobject.h π intrcheck.h π modsupport.h π osmodule.h π pydtrace.h π pymacro.h π pystrtod.h π setobject.h π typeslots.h
π ceval.h π descrobject.h π fileutils.h π iterobject.h π moduleobject.h π patchlevel.h π pyerrors.h π pymath.h π Python.h π sliceobject.h π unicodeobject.h
```
```shell
β² ls lib/
π pkgconfig π python3.15
```
```shell
β² ls lib/pkgconfig/
π python-3.15-embed.pc π python-3.15.pc π python3-embed.pc π python3.pc
```
```shell
β² ls lib/python3.15/
π __future__.py π _pyio.py π calendar.py π dataclasses.py π gettext.py π locale.py π platform.py π sched.py π symtable.py π types.py
π __hello__.py π _pylong.py π cmd.py π datetime.py π glob.py π logging π plistlib.py π secrets.py π sysconfig π typing.py
π __phello__ π _pyrepl π code.py π dbm π graphlib.py π lzma.py π poplib.py π selectors.py π tabnanny.py π unittest
π __pycache__ π _sitebuiltins.py π codecs.py π decimal.py π gzip.py π mailbox.py π posixpath.py π shelve.py π tarfile.py π urllib
π _aix_support.py π _strptime.py π codeop.py π difflib.py π hashlib.py π mimetypes.py π pprint.py π shlex.py π tempfile.py π uuid.py
π _android_support.py π _sysconfig_vars__linux_x86_64-linux-gnu.json π collections π dis.py π heapq.py π modulefinder.py π profile.py π shutil.py π test π venv
π _apple_support.py π _sysconfigdata__linux_x86_64-linux-gnu.py π colorsys.py π doctest.py π hmac.py π multiprocessing π profiling π signal.py π textwrap.py π warnings.py
π _ast_unparse.py π _threading_local.py π compileall.py π email π html π netrc.py π pstats.py π site-packages π this.py π wave.py
π _collections_abc.py π _weakrefset.py π compression π encodings π http π ntpath.py π pty.py π site.py π threading.py π weakref.py
π _colorize.py π abc.py π concurrent π ensurepip π idlelib π nturl2path.py π py_compile.py π smtplib.py π timeit.py π webbrowser.py
π _compat_pickle.py π annotationlib.py π config-3.15-x86_64-linux-gnu π enum.py π imaplib.py π numbers.py π pyclbr.py π socket.py π tkinter π wsgiref
π _ios_support.py π antigravity.py π configparser.py π filecmp.py π importlib π opcode.py π pydoc.py π socketserver.py π token.py π xml
π _markupbase.py π argparse.py π contextlib.py π fileinput.py π inspect.py π operator.py π pydoc_data π sqlite3 π tokenize.py π xmlrpc
π _missing_stdlib_info.py π ast.py π contextvars.py π fnmatch.py π io.py π optparse.py π queue.py π ssl.py π tomllib π zipapp.py
π _opcode_metadata.py π asyncio π copy.py π fractions.py π ipaddress.py π os.py π quopri.py π stat.py π trace.py π zipfile
π _osx_support.py π base64.py π copyreg.py π ftplib.py π json π pathlib π random.py π statistics.py π traceback.py π zipimport.py
π _py_abc.py π bdb.py π cProfile.py π functools.py π keyword.py π pdb.py π re π string π tracemalloc.py π zoneinfo
π _py_warnings.py π bisect.py π csv.py π genericpath.py π lib-dynload π pickle.py π reprlib.py π stringprep.py π tty.py
π _pydatetime.py π build-details.json π ctypes π getopt.py π LICENSE.txt π pickletools.py π rlcompleter.py π struct.py π turtle.py
π _pydecimal.py π bz2.py π curses π getpass.py π linecache.py π pkgutil.py π runpy.py π subprocess.py π turtledemo
```
```shell
/tmp/cp-install
β² ls lib/python3.15/lib-dynload/
π _bisect.cpython-315-x86_64-linux-gnu.so π _heapq.cpython-315-x86_64-linux-gnu.so π _sha2.cpython-315-x86_64-linux-gnu.so π _zoneinfo.cpython-315-x86_64-linux-gnu.so π zlib.cpython-315-x86_64-linux-gnu.so
π _blake2.cpython-315-x86_64-linux-gnu.so π _hmac.cpython-315-x86_64-linux-gnu.so π _sha3.cpython-315-x86_64-linux-gnu.so π _zstd.cpython-315-x86_64-linux-gnu.so
π _bz2.cpython-315-x86_64-linux-gnu.so π _interpchannels.cpython-315-x86_64-linux-gnu.so π _socket.cpython-315-x86_64-linux-gnu.so π array.cpython-315-x86_64-linux-gnu.so
π _codecs_cn.cpython-315-x86_64-linux-gnu.so π _interpqueues.cpython-315-x86_64-linux-gnu.so π _sqlite3.cpython-315-x86_64-linux-gnu.so π binascii.cpython-315-x86_64-linux-gnu.so
π _codecs_hk.cpython-315-x86_64-linux-gnu.so π _interpreters.cpython-315-x86_64-linux-gnu.so π _ssl.cpython-315-x86_64-linux-gnu.so π cmath.cpython-315-x86_64-linux-gnu.so
π _codecs_iso2022.cpython-315-x86_64-linux-gnu.so π _json.cpython-315-x86_64-linux-gnu.so π _statistics.cpython-315-x86_64-linux-gnu.so π fcntl.cpython-315-x86_64-linux-gnu.so
π _codecs_jp.cpython-315-x86_64-linux-gnu.so π _lsprof.cpython-315-x86_64-linux-gnu.so π _struct.cpython-315-x86_64-linux-gnu.so π grp.cpython-315-x86_64-linux-gnu.so
π _codecs_kr.cpython-315-x86_64-linux-gnu.so π _lzma.cpython-315-x86_64-linux-gnu.so π _testbuffer.cpython-315-x86_64-linux-gnu.so π math.cpython-315-x86_64-linux-gnu.so
π _codecs_tw.cpython-315-x86_64-linux-gnu.so π _math_integer.cpython-315-x86_64-linux-gnu.so π _testcapi.cpython-315-x86_64-linux-gnu.so π mmap.cpython-315-x86_64-linux-gnu.so
π _csv.cpython-315-x86_64-linux-gnu.so π _md5.cpython-315-x86_64-linux-gnu.so π _testclinic.cpython-315-x86_64-linux-gnu.so π pyexpat.cpython-315-x86_64-linux-gnu.so
π _ctypes.cpython-315-x86_64-linux-gnu.so π _multibytecodec.cpython-315-x86_64-linux-gnu.so π _testclinic_limited.cpython-315-x86_64-linux-gnu.so π readline.cpython-315-x86_64-linux-gnu.so
π _ctypes_test.cpython-315-x86_64-linux-gnu.so π _multiprocessing.cpython-315-x86_64-linux-gnu.so π _testimportmultiple.cpython-315-x86_64-linux-gnu.so π resource.cpython-315-x86_64-linux-gnu.so
π _curses.cpython-315-x86_64-linux-gnu.so π _pickle.cpython-315-x86_64-linux-gnu.so π _testinternalcapi.cpython-315-x86_64-linux-gnu.so π select.cpython-315-x86_64-linux-gnu.so
π _curses_panel.cpython-315-x86_64-linux-gnu.so π _posixshmem.cpython-315-x86_64-linux-gnu.so π _testlimitedcapi.cpython-315-x86_64-linux-gnu.so π syslog.cpython-315-x86_64-linux-gnu.so
π _dbm.cpython-315-x86_64-linux-gnu.so π _posixsubprocess.cpython-315-x86_64-linux-gnu.so π _testmultiphase.cpython-315-x86_64-linux-gnu.so π termios.cpython-315-x86_64-linux-gnu.so
π _decimal.cpython-315-x86_64-linux-gnu.so π _queue.cpython-315-x86_64-linux-gnu.so π _testsinglephase.cpython-315-x86_64-linux-gnu.so π unicodedata.cpython-315-x86_64-linux-gnu.so
π _elementtree.cpython-315-x86_64-linux-gnu.so π _random.cpython-315-x86_64-linux-gnu.so π _tkinter.cpython-315-x86_64-linux-gnu.so π xxlimited.cpython-315-x86_64-linux-gnu.so
π _gdbm.cpython-315-x86_64-linux-gnu.so π _remote_debugging.cpython-315-x86_64-linux-gnu.so π _uuid.cpython-315-x86_64-linux-gnu.so π xxlimited_35.cpython-315-x86_64-linux-gnu.so
π _hashlib.cpython-315-x86_64-linux-gnu.so π _sha1.cpython-315-x86_64-linux-gnu.so π _xxtestfuzz.cpython-315-x86_64-linux-gnu.so π xxsubtype.cpython-315-x86_64-linux-gnu.so
```
```shell
β² ls share/man/man1/
π python3.1 π python3.15.1
```
## Debug
Only listing differences with a release build.
```shell
β² ls bin/
idle3 pip3 pydoc3 python3 python3.15 python3.15d
idle3.15 pip3.15 pydoc3.15 python3-config python3.15-config python3.15d-config
```
```shell
β² ls include/python3.15d/
abstract.h datetime.h import.h objimpl.h pyerrors.h pystrcmp.h sysmodule.h
audit.h descrobject.h internal opcode.h pyexpat.h pystrtod.h traceback.h
bltinmodule.h dictobject.h intrcheck.h opcode_ids.h pyframe.h Python.h tupleobject.h
boolobject.h dynamic_annotations.h iterobject.h osdefs.h pyhash.h pythonrun.h typeslots.h
bytearrayobject.h enumobject.h listobject.h osmodule.h pylifecycle.h pythread.h unicodeobject.h
bytesobject.h errcode.h longobject.h patchlevel.h pymacconfig.h pytypedefs.h warnings.h
ceval.h exports.h marshal.h py_curses.h pymacro.h rangeobject.h weakrefobject.h
codecs.h fileobject.h memoryobject.h pyatomic.h pymath.h refcount.h
compile.h fileutils.h methodobject.h pybuffer.h pymem.h setobject.h
complexobject.h floatobject.h modsupport.h pycapsule.h pyport.h sliceobject.h
cpython frameobject.h moduleobject.h pyconfig.h pystate.h structmember.h
critical_section.h genericaliasobject.h object.h pydtrace.h pystats.h structseq.h
```
```
```shell
β² ls lib/pkgconfig/
python-3.15-embed.pc python-3.15.pc python-3.15d-embed.pc python-3.15d.pc python3-embed.pc python3.pc
```