This is an attempt at using Nix to create a local development environment for the WASI build of Python.
Assuming you already have Nix installed with flakes enabled.
-
Clone the repo
$ git clone https://github.com/alcarney/python-wasi-nix $ cd python-wasi-nix -
Activate the
devShell$ nix develop -
Run the script
$ python main.py sys.platform='wasi' {'line': 1, 'character': 42}
- Setting up a Python WASI Environment with Nix: The blog post outlining how the Nix parts of this repo work
- Testing a Python project using the WASI build of CPython with pytest: The blog post that covers the Python + WASI part of this repo
- WebAssembly and its platform targets: Overview of the different WebAssembly runtimes
This is "good enough" for me to start hacking on the WASI runtime, but there's certainly plenty that could potnetially be improved.
- Building Python WASI from source
- Automatically choosing the right Python package set to use with
mkPythonWASIShell, likepython.withPackages - Extending
mkPythonWASIShellto allow the user to set the permissions for the Python process - Overriding a base
pythonderivation so that packages are built against this version of Python. - Extending this to work with packages that contain native modules?