These are the steps I use to build Nova Physics's Python Binding for pygbag. Hope it helps you build your own third-party pygbag wheels 💕
- Ubuntu 22 (or higher) WSL works as well. (glibc 2.35+ is required.)
-
Be in the root directory (we will extract stuff into
/opt
). -
Download the latest
python-wasm-sdk
release from here. (I had to download a slightly older release.)$ wget https://github.com/pygame-web/python-wasm-sdk/releases/download/3.1.62.1bi/python3.12-wasm-sdk-Ubuntu-22.04.tar.lz4
-
Install
lz4
if not already installed.$ apt install lz4
-
Decompress
python-wasm-sdk
. After this step, you should have/opt/python-wasm-sdk
.$ tar --use-compress-program=lz4 -xvf python3.12-wasm-sdk-Ubuntu-22.04.tar.lz4
-
We're done setting up
python-wasm-sdk
. Now we need the package we're going to build the wheels for with asetup.py
. I will use my own project as an example.$ git clone https://github.com/kadir014/nova-physics-python.git $ cd nova-physics-python
-
Use the cross-compiler to build the pygbag wheels.
$ /opt/python-wasm-sdk/python3-wasm setup.py bdist_wheel
-
If successful, you should have the built package under the directory
build/lib.wasm32-bi-emscripten-cpython-<version>
. And the wheel underdist/
.
- If your package is a C-extension, you may want to play with compilation optimization levels,
-O3
caused few problems to me. emcc
doesn't accept-march
argument, so remove that when building withpython3-wasm
.- For some reason I also had to download Python 3.10.