This directory contains configuration and helpers to facilitate cross compilation of CPython to WebAssembly (WASM).
Cross compiling to wasm32-emscripten platform needs the Emscripten tool chain and a build Python interpreter. All commands below are relative to a repository checkout.
mkdir -p builddir/build
pushd builddir/build
../../configure -C
make -j$(nproc)
popdembuilder build zlibFor browser:
mkdir -p builddir/emscripten
pushd builddir/emscripten
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-emscripten \
emconfigure ../../configure -C \
--host=wasm32-unknown-emscripten \
--build=$(../../config.guess) \
--with-emscripten-target=browser \
--with-build-python=$(pwd)/../build/python
emmake make -j$(nproc)For node:
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-emscripten \
emconfigure ../../configure -C \
--host=wasm32-unknown-emscripten \
--build=$(../../config.guess) \
--with-emscripten-target=node \
--with-build-python=$(pwd)/../build/python
emmake make -j$(nproc)
Serve python.html with a local webserver and open the file in a browser.
emrun python.htmlor
python3 -m http.server