# Useful links - [Issues](https://github.com/python/cpython/labels/OS-wasi) - [Buildbots](https://buildbot.python.org/#/builders?tags=%2Bwasi) # Plans - [ ] Simplify building releases (branch off for Python 3.12 and 3.11, then switch to `wasi.py` so I can select the branch of the repo when doing the builds) - [ ] [Dev container](https://github.com/python/cpython-devcontainers) image - [ ] [proper CPU support](https://docs.docker.com/build/building/multi-platform/#cross-compilation) ([issue](https://github.com/python/cpython-devcontainers/issues/25)) - [ ] [Development in general](https://github.com/python/cpython-devcontainers/issues/12) - [ ] [`.devcontainer`](https://github.com/python/cpython/tree/main/.devcontainer) (make sure to point to `latest` for all dev containers) - [ ] [CI](https://github.com/python/cpython/blob/main/.github/workflows/reusable-wasi.yml) ([issue](https://github.com/python/cpython-devcontainers/issues/26)) - [ ] Build [releases](https://github.com/brettcannon/cpython-wasi-build) - [ ] Test [WASI SDK 25](https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-25) - [ ] [Stop setting `HOSTRUNNER` in `configure.ac`](https://github.com/python/cpython/issues/95952) - [x] [Stop using `./configure` directly to build in the buildbots](https://github.com/python/buildmaster-config/pull/526) - [ ] Update `configure.ac` - [ ] [Create a GitHub Action to install WASI SDK](https://github.com/WebAssembly/wasi-sdk/issues/468) (? Might not be necessary w/ a container image used in CI) - [ ] Get 3rd-party extensions working (static build is fine) - [ ] NumPy - [ ] Pandas - [ ] Set up Black formatting for `wasi.py` - [ ] Move `wasi.py` functionality to `wasi/__main__.py` - [ ] Copy code over and leave deprecated stub behind - [ ] Update `CODEOWNERS` - [ ] I own `wasi.py` - [ ] I own `wasi/` - [ ] Jointly own `README` - [ ] Update buildbots - [ ] `wasi.py package` - [ ] Single-file `python.wasm` distribution - [ ] [External dependencies](https://github.com/python/cpython-source-deps) - [ ] Find out what version policy we want (i.e. always latest or freeze versions? Windows freezes) - [ ] zlib - [ ] 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 - [x] OpenSSL (not safe as WebAssembly doesn't have constant time ops) - [ ] Freeze entire applicable stdlib - [ ] [Support `wasm32-wasip2`](https://github.com/python/cpython/issues/121634) - [x] Ability to specify host triple - [x] Find out if `wasip2` is compatible w/ preview1 hosts - [ ] buildbot - [ ] PEP 11 - [ ] Networking under WASI 0.2 - [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 - [ ] [Check](https://github.com/python/cpython/issues/115982) the [site config](https://github.com/python/cpython/blob/main/Tools/wasm/config.site-wasm32-wasi) is up-to-date - [ ] Help get [WASIX](https://github.com/singlestore-labs/wasix) upstreamed to [wasi-libc](https://github.com/WebAssembly/wasi-libc) - [ ] Try compiling MicroPython to WASI thanks to `longjmp` support (if VS Code wants it) - [PR for wasi-libc](https://github.com/WebAssembly/wasi-libc/pull/483) - [Convention docs](https://github.com/WebAssembly/tool-conventions/blob/main/SetjmpLongjmp.md) # Ideas ## Live REPL on docs.python.org Use [JCO](https://github.com/bytecodealliance/jco) to get working in the browser. Use for examples in docs. Can also create a REPL somewhere, e.g. repl.python.org or play.python.org . ## Faster startup https://bytecodealliance.org/articles/making-javascript-run-fast-on-webassembly ## Single-file apps Can probably use https://github.com/bytecodealliance/WASI-Virt to store Python files along w/ [[#^binary-wheels]]. Should be able to do [minimal builds of Wasmtime](https://docs.wasmtime.dev/examples-minimal.html) to help shrink the overall size. ## HTTP fetch API Create an [[HTTP fetch API]] and have that use [wasi-http](https://github.com/WebAssembly/wasi-http). This avoids OpenSSL. ## Dynamic loading of components Lack of support is what caused [Cloudflare to go with Pyodide](https://blog.cloudflare.com/python-workers/) (supposedly). ## Binary wheels - [ ] Binary wheels ^binary-wheels - [ ] Figure out _how_ this would work in terms of importing - [ ] Platform tag - [x] See what the generic wheel tag is - [ ] Figure out what info needs to be covered by a WASI platform tag - [ ] Write a PEP - [ ] Tool to take an extension module wheel and `.py` files and create a single `wasm` file ### Default tag list ``` cp312-cp312-wasi_0_0_0_wasm32 cp312-abi3-wasi_0_0_0_wasm32 cp312-none-wasi_0_0_0_wasm32 cp311-abi3-wasi_0_0_0_wasm32 cp310-abi3-wasi_0_0_0_wasm32 cp39-abi3-wasi_0_0_0_wasm32 cp38-abi3-wasi_0_0_0_wasm32 cp37-abi3-wasi_0_0_0_wasm32 cp36-abi3-wasi_0_0_0_wasm32 cp35-abi3-wasi_0_0_0_wasm32 cp34-abi3-wasi_0_0_0_wasm32 cp33-abi3-wasi_0_0_0_wasm32 cp32-abi3-wasi_0_0_0_wasm32 py312-none-wasi_0_0_0_wasm32 py3-none-wasi_0_0_0_wasm32 py311-none-wasi_0_0_0_wasm32 py310-none-wasi_0_0_0_wasm32 py39-none-wasi_0_0_0_wasm32 py38-none-wasi_0_0_0_wasm32 py37-none-wasi_0_0_0_wasm32 py36-none-wasi_0_0_0_wasm32 py35-none-wasi_0_0_0_wasm32 py34-none-wasi_0_0_0_wasm32 py33-none-wasi_0_0_0_wasm32 py32-none-wasi_0_0_0_wasm32 py31-none-wasi_0_0_0_wasm32 py30-none-wasi_0_0_0_wasm32 cp312-none-any py312-none-any py3-none-any py311-none-any py310-none-any py39-none-any py38-none-any py37-none-any py36-none-any py35-none-any py34-none-any py33-none-any py32-none-any py31-none-any py30-none-any ``` --- # 2024 Plumber's Summit Brett Cannon Microsoft 2024-09-27 https://opensource.snarky.ca/Python/WASI --- ## How it all started "You should fix that ..." --- ## Current status - [Tier 2 platform](https://peps.python.org/pep-0011/#tier-2) for CPython under `wasm32-wasi` - Starting in Python 3.13 (due out in a week!) - Tested under [wasmtime](https://github.com/bytecodealliance/wasmtime) 22 & [WASI SDK](https://github.com/WebAssembly/wasi-sdk) 24 [in CI](https://github.com/python/cpython/blob/main/.github/workflows/reusable-wasi.yml) - [Tier 3](https://peps.python.org/pep-0011/#tier-3) for Python 3.11, 3.12 - Tested [via buildbots](https://buildbot.python.org/all/#/builders?tags=%2Bwasi&tags=%2Bstable) --- ## Plans --- ### Maintenance - Switch to `wasm32-wasip1` as the supported triple - Set up a dev [container with wasmtime and WASI SDK](https://github.com/python/cpython-devcontainers/issues/12) --- ### Enhancements - Try to build [NumPy](https://numpy.org/) and [pandas](https://pandas.pydata.org) into a `python.wasm` binary - Get [external dependencies](https://github.com/python/cpython-source-deps) like zlib compiled into `python.wasm` - Get a self-contained `python.wasm` - Official releases of `python.wasm` - `wasm32-wasip2` (at the bottom for a reason) --- ## Wish List --- ### Threading - VS Code wants it - [`test_socket`](https://github.com/python/cpython/blob/main/Lib/test/test_socket.py) needs it - Free-threading experiment starting in Python 3.13 (aka no more GIL) - This gets Python to `wasm32-wasip2` with networking --- ### Dynamic linking - Python developers expect to download a `.whl` file w/ a `.so` and be done - Currently [`componentize-py`](https://github.com/bytecodealliance/componentize-py) needs to add a step to embed the `.so` into `python.wasm` - JIT experiment starting in Python 3.13