Improved experience in building for WASI

I just landed a PR which adds Tools/wasm/wasi.py to make it easier to build CPython for WASI. The docs can be found at https://github.com/python/cpython/tree/main/Tools/wasm#wasi-wasm32-wasi . Hopefully this will make it easier to diagnose any issues you might come across with WASI (although the vast majority of them are from assuming threads or a certain stack size).

6 Likes

Thank you @brettcannon!

1 Like

Does anyone if the build recipe of the quay.io/tiran/cpythonbuild:emsdk3 container is public? If yes, would anyone be interested to take over the maintenance of this container? It seems like it wasn’t update for a few months.

The cpythonbuild containers comes from GitHub - tiran/cpython_builddep: Install CPython build and development dependencies if I’m not mistaken.

1 Like

Why do you specifically want that container maintained? I already keep https://github.com/python/cpython/tree/main/.devcontainer updated. Plus, for WASI, it’s installing two things which are self-contained, so it isn’t costly to get going.

I have no idea how to use this container. Can I install it and run it locally on Linux?

Setup and building are instructions on how to use GitHub Codespaces. There’s also a Dockerfile in there if you want to create your own container from the same files. If you’re a VS Code user or use some other editor that supports devcontainers it can build the container for you. But if you look at that Dockerfile you will notice it’s based on Fedora and there’s two key commands to get the two key tools installed: https://github.com/python/cpython/blob/674c288b1c29b5d838c0cb6de0ea7a64caf294ff/.devcontainer/Dockerfile#L16-L24 .

There’s GitHub - WebAssembly/wasi-sdk: WASI-enabled WebAssembly C/C++ toolchain if you want a container image for the WASI SDK, probably leaving just installing some WASI host/runtime like wasmtime into it once you launch it (assuming it doesn’t already have it).

Oh ok, I found Setup and building doc. I’m not using GitHub Codespace nor VS Code nor any editor using container.

Well, I would prefer to not install these tools locally, but use a container for that. It’s more convenient for me. So Christian’s container just works as expected for my use case :wink: I just have to run a command, it’s quick (once the image is downloaded, it’s cached locally), and I can work in the container.

I get that, but there’s a Dockerfile at https://github.com/python/cpython/blob/main/.devcontainer/Dockerfile#L16-L24 that installs everything you need, so I’m not sure what else you want beyond someone to push a built container to some container registry for you.

If that is what you want, someone could probably set up some CI that pushes to Working with the Container registry - GitHub Docs whenever that Dockerfile changes so it’s available externally.

Yep, I need that :slight_smile:

1 Like

Unfortunately I don’t know containers well enough to know how best to set that up in an automated way that won’t lead to you coming back to me saying, “you did it wrong” :wink: (I’m still impressed I got the Dockerfile set up appropriately). For instance, assuming I could get permissions to push a container to ghcr.io from the CPython repo and I used Publishing and installing a package with GitHub Actions - GitHub Docs , I don’t know what labels and tags are for.

If it’s helpful, here’s a Github Actions workflow fly that builds docker images and pushes them to Github Container Registry: https://github.com/pyca/infra/blob/main/.github/workflows/build-docker-images.yml

(It’s a bit more complex because it supports multiple architectures and is a matrix build, but hopefully the relevant bits are clear.)

2 Likes