Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pygame-ce wheel build (WIP) #20

Open
pmp-p opened this issue Apr 4, 2023 · 1 comment
Open

pygame-ce wheel build (WIP) #20

pmp-p opened this issue Apr 4, 2023 · 1 comment

Comments

@pmp-p
Copy link
Member

pmp-p commented Apr 4, 2023

python-wasm :
use pygbag CI

pyodide ( with a pyodide venv ):

#!/bin/bash
TAG=311


REPACK=/data/git/pyodide/packages/pygame-ce/dist/repack

mkdir -p $REPACK
rm $REPACK/../*.whl

. /opt/python-wasm-sdk/wasm32-mvp-emscripten-shell.sh
unset _PYTHON_SYSCONFIGDATA_NAME

cd /data/git/pyodide


[ -f .venv-pyodide/bin/activate ] || pyodide venv .venv-pyodide

source .venv-pyodide/bin/activate
cd packages/pygame-ce


PORTS="-sUSE_SDL=2 -sUSE_SDL_MIXER=2 -sUSE_LIBPNG -sUSE_LIBJPEG -sUSE_SDL_TTF=2"
SDL2_IMAGE="-I/opt/python-wasm-sdk/devices/emsdk/usr/include/SDL2 -L/opt/python-wasm-sdk/devices/emsdk/usr/lib"
SDL2_TTF="-I/opt/python-wasm-sdk/emsdk/upstream/emscripten/cache/sysroot/include/freetype2 -L/opt/python-wasm-sdk/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lSDL2_ttf"

# use bigint
export MVP=false

EMCC_CFLAGS="-sASYNCIFY -sWASM_BIGINT -DBUILD_STATIC -fpic \
 ${SDL2_IMAGE} ${SDL2_TTF} ${PORTS}" \
 PYODIDE_EMSCRIPTEN_VERSION=3.1.34 \
 pyodide build

OBJS=$(find build/temp.emscripten_*/|grep o$)


TARGET=$REPACK/pygame_static.cpython-${TAG}-wasm32-emscripten.so

$SDKROOT/emsdk/upstream/emscripten/emar rcs ${SDKROOT}/prebuilt/emsdk/libpygame${PYBUILD}.a $OBJS
emcc -sWASM_BIGINT -shared -Os -g0 -fpic -o $TARGET $SDKROOT/prebuilt/emsdk/libpygame${PYMAJOR}.${PYMINOR}.a

cd /data/git/pyodide/packages/pygame-ce/dist/repack

unzip -o ../*.whl


grep -v emscripten pygame_ce-2.3.0.dev1.dist-info/RECORD > R
echo "pygame_static.cpython-${TAG}-wasm32-emscripten.so,," >> R
mv R pygame_ce-2.3.0.dev1.dist-info/RECORD

zip ../pygame_ce-2.3.0.dev1-cp311-cp311-emscripten_3_1_34_wasm32.whl -r .

actual result Successfully built /data/git/pyodide/packages/pygame-ce/dist/pygame_ce-2.3.0.dev1-cp311-cp311-emscripten_3_1_34_wasm32.whl

ref:
https://pyodide.org/en/stable/development/building-and-testing-packages.html
https://github.com/ryanking13/pyodide/blob/94030d71163dbf616b24888a9d99dc3b1b440edd/packages/pygame-ce/meta.yaml

@pmp-p
Copy link
Member Author

pmp-p commented Nov 26, 2023

i'm quite sure there is a heisenbug in display.init() linked to the way pygame.base is imported ( the wasm part including multiphase init that load all modules at once)

for now pygbag way of loading pygame seems the only "safe" way until pep0723 is adopted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant