Pyodide#

This site is essential! Under the hood, pyodide uses emscripten. Thus, install the emsdk. On Linux, do not use your package manager for this - emscripten will need to be able to manage it’s own version. Add

export EMSDK_QUIET=1
source "/home/norberth/software/emsdk/emsdk_env.sh"

to your .bashrc or .zshrc on Linux or MacOS or do the equivalent under Windows (see emscripten documentation).

Apart from that, install pyodide-build using pip. Make sure to use a version of pyodide-build that was released after March 30, 2024, such as 0.25.1. Some earlier versions - like the alpha versions of 0.26.0 - won’t work.

Run

PYODIDE_EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version)
emsdk install ${PYODIDE_EMSCRIPTEN_VERSION}
emsdk activate ${PYODIDE_EMSCRIPTEN_VERSION}

Now, python -m build can be replaced with

pyodide build

Now, foo/dist should contain another wheel with emscripten in it’s name. This file is what is needed.