Skip to content

Commit

Permalink
3.1.72pre
Browse files Browse the repository at this point in the history
  • Loading branch information
pmp-p committed Nov 20, 2024
1 parent ed75440 commit 4516d10
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
runs-on: ubuntu-22.04
env:
BUILDS: 3.12 3.13
SDKROOT: /opt/python-wasm-sdk
EMFLAVOUR: latest
Py_GIL_DISABLED: false
wasisdk: true
Expand Down
8 changes: 6 additions & 2 deletions emsdk-cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ for argc, arg in enumerate(sys.argv):
AOUT = sys.argv[out_pos]

elif not STATIC:
if arg.endswith(".so") or arg == "-shared" or arg.find("SIDE_MODULE") > 0:
if arg.endswith(".so") and arg.startswith("/usr/lib"):
arg = f"-l{arg.rsplit('/',1)[-1][3:-3]}"
if arg in ('-lportmidi','-lporttime'):
continue
elif arg.endswith(".so") or arg == "-shared" or arg.find("SIDE_MODULE") > 0:
IS_SHARED = True
if arg == "-shared":
pass
Expand Down Expand Up @@ -393,7 +397,7 @@ else:
# TODO: module level
# -gsource-map --source-map-base /
pass
final.extend(arglist(WASM_EXTRA, "-DBUILD_STATIC"))
final.extend(arglist(WASM_EXTRA, "-DPYDK_STATIC"))

final.extend(out)
final.extend(COMMON)
Expand Down
27 changes: 16 additions & 11 deletions python-wasi-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ do

[ -f $HPY ] || exit 106


cat > /opt/python-wasm-sdk/devices/$(arch)/usr/bin/py <<END
#!/bin/bash
export XDG_SESSION_TYPE=x11
Expand Down Expand Up @@ -183,7 +184,9 @@ END
then
cd ${SDKROOT}

mkdir -p src build ${SDKROOT}/devices/emsdk ${SDKROOT}/prebuilt/emsdk
export TARGET=emsdk

mkdir -p src build ${SDKROOT}/devices/${TARGET} ${SDKROOT}/prebuilt/${TARGET}

if [ -f /tmp/emsdk.tar ]
then
Expand Down Expand Up @@ -217,7 +220,7 @@ END
then
echo " using cached cpython-build-emsdk-deps"
else
if ./scripts/cpython-build-emsdk-deps.sh
if ./scripts/cpython-build-${TARGET}-deps.sh
then
# if $CI
if false
Expand Down Expand Up @@ -246,11 +249,11 @@ END
fi

echo " ------------ building cpython wasm ${PYBUILD} ${CIVER} ----------------" 1>&2
if ./scripts/cpython-build-emsdk.sh > /dev/null
if ./scripts/cpython-build-${TARGET}.sh > /dev/null
then

echo " --------- adding some usefull pkg ${PYBUILD} ${CIVER} ---------" 1>&2
./scripts/cpython-build-emsdk-prebuilt.sh || exit 223
./scripts/cpython-build-${TARGET}-prebuilt.sh || exit 223


# experimental stuff
Expand Down Expand Up @@ -282,34 +285,36 @@ END
then
cd ${SDKROOT}

export TARGET=wasi

mkdir -p src build ${SDKROOT}/devices/wasisdk ${SDKROOT}/prebuilt/wasisdk

# do not source to protect env
./scripts/cpython-build-wasisdk.sh

> ${SDKROOT}/python3-wasi
> ${SDKROOT}/python3-${TARGET}

# ROOT=/opt/python-wasm-sdk SDKROOT=/opt/python-wasm-sdk
# HOST_PREFIX=/opt/python-wasm-sdk/devices/$(arch)/usr
> ${SDKROOT}/wasm32-wasi-shell.sh
> ${SDKROOT}/wasm32-${TARGET}-shell.sh

CPU=wasm32 TARGET=wasi \
PYDK_PYTHON_HOST_PLATFORM=wasm32-wasi \
CPU=wasm32 TARGET=$TARGET \
PYDK_PYTHON_HOST_PLATFORM=wasm32-${TARGET} \
PREFIX=/opt/python-wasm-sdk/devices/wasisdk/usr \
./scripts/make-shells.sh

cat >> $ROOT/wasm32-wasi-shell.sh <<END
cat >> $ROOT/wasm32-${TARGET}-shell.sh <<END
#!/bin/bash
. ${WASISDK}/wasisdk_env.sh
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="[PyDK:wasi] \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]\$ "
export PS1="[PyDK:${TARGET}] \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]\$ "
END
chmod +x ${SDKROOT}/python3-wasi ${SDKROOT}/wasm32-wasi-shell.sh
chmod +x ${SDKROOT}/python3-${TARGET} ${SDKROOT}/wasm32-${TARGET}-shell.sh

fi

Expand Down
27 changes: 16 additions & 11 deletions python-wasm-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ do

[ -f $HPY ] || exit 106


cat > /opt/python-wasm-sdk/devices/$(arch)/usr/bin/py <<END
#!/bin/bash
export XDG_SESSION_TYPE=x11
Expand Down Expand Up @@ -183,7 +184,9 @@ END
then
cd ${SDKROOT}

mkdir -p src build ${SDKROOT}/devices/emsdk ${SDKROOT}/prebuilt/emsdk
export TARGET=emsdk

mkdir -p src build ${SDKROOT}/devices/${TARGET} ${SDKROOT}/prebuilt/${TARGET}

if [ -f /tmp/emsdk.tar ]
then
Expand Down Expand Up @@ -217,7 +220,7 @@ END
then
echo " using cached cpython-build-emsdk-deps"
else
if ./scripts/cpython-build-emsdk-deps.sh
if ./scripts/cpython-build-${TARGET}-deps.sh
then
# if $CI
if false
Expand Down Expand Up @@ -246,11 +249,11 @@ END
fi

echo " ------------ building cpython wasm ${PYBUILD} ${CIVER} ----------------" 1>&2
if ./scripts/cpython-build-emsdk.sh > /dev/null
if ./scripts/cpython-build-${TARGET}.sh > /dev/null
then

echo " --------- adding some usefull pkg ${PYBUILD} ${CIVER} ---------" 1>&2
./scripts/cpython-build-emsdk-prebuilt.sh || exit 223
./scripts/cpython-build-${TARGET}-prebuilt.sh || exit 223


# experimental stuff
Expand Down Expand Up @@ -282,34 +285,36 @@ END
then
cd ${SDKROOT}

export TARGET=wasi

mkdir -p src build ${SDKROOT}/devices/wasisdk ${SDKROOT}/prebuilt/wasisdk

# do not source to protect env
./scripts/cpython-build-wasisdk.sh

> ${SDKROOT}/python3-wasi
> ${SDKROOT}/python3-${TARGET}

# ROOT=/opt/python-wasm-sdk SDKROOT=/opt/python-wasm-sdk
# HOST_PREFIX=/opt/python-wasm-sdk/devices/$(arch)/usr
> ${SDKROOT}/wasm32-wasi-shell.sh
> ${SDKROOT}/wasm32-${TARGET}-shell.sh

CPU=wasm32 TARGET=wasi \
PYDK_PYTHON_HOST_PLATFORM=wasm32-wasi \
CPU=wasm32 TARGET=$TARGET \
PYDK_PYTHON_HOST_PLATFORM=wasm32-${TARGET} \
PREFIX=/opt/python-wasm-sdk/devices/wasisdk/usr \
./scripts/make-shells.sh

cat >> $ROOT/wasm32-wasi-shell.sh <<END
cat >> $ROOT/wasm32-${TARGET}-shell.sh <<END
#!/bin/bash
. ${WASISDK}/wasisdk_env.sh
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="[PyDK:wasi] \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]\$ "
export PS1="[PyDK:${TARGET}] \[\e[32m\]\w \[\e[91m\]\$(parse_git_branch)\[\e[00m\]\$ "
END
chmod +x ${SDKROOT}/python3-wasi ${SDKROOT}/wasm32-wasi-shell.sh
chmod +x ${SDKROOT}/python3-${TARGET} ${SDKROOT}/wasm32-${TARGET}-shell.sh

fi

Expand Down
27 changes: 22 additions & 5 deletions scripts/cpython-build-emsdk-prebuilt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ rm ${SDKROOT}/prebuilt/emsdk/common/site-packages/installer/_scripts/*exe



# SDL2 is prebuilt in emsdk but lacks pkg config *.pc, wasi has them

if $WASI
then
echo -n
else
SYSROOT=${SDKROOT}/emsdk/upstream/emscripten/cache/sysroot

# SDL2 is prebuilt in emsdk but lacks SDL2.pc

cat > ${PREFIX}/lib/pkgconfig/sdl2.pc <<END
cat > ${PREFIX}/lib/pkgconfig/sdl2.pc <<END
# sdl pkg-config source file
prefix=${PREFIX}
Expand All @@ -167,12 +171,25 @@ Version: 2.31.0
Requires.private:
Conflicts:
Libs: -L\${libdir} -lSDL2 -lm
Cflags: -I\${includedir} -I\${includedir}/SDL2
Cflags: -I\${includedir} -I\${includedir}/SDL2 -I${SYSROOT}/include/SDL2 -I${SYSROOT}/include/freetype2"
END

cat > ${PREFIX}/lib/pkgconfig/SDL2_mixer.pc <<END
prefix=${PREFIX}/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: SDL2_mixer
Description: mixer library for Simple DirectMedia Layer
Version: 2.8.0
Requires: sdl2 >= 2.0.9
Libs: -L\${libdir} -lSDL2_mixer
Cflags: -I\${includedir}/SDL2
Requires.private:
Libs.private:

fi
8 changes: 4 additions & 4 deletions scripts/cpython-build-emsdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ END
if [ -d $PREFIX/lib/python${PYBUILD}/lib-dynload ]
then
# move them to MEMFS
mv $PREFIX/lib/python${PYBUILD}/lib-dynload/* ${SDKROOT}/prebuilt/emsdk/${PYBUILD}/lib-dynload/
mv $PREFIX/lib/python${PYBUILD}/lib-dynload/* ${SDKROOT}/prebuilt/${TARGET}/${PYBUILD}/lib-dynload/

echo " =============== FIXME: _ctype dynamic build ==============="
rm ${SDKROOT}/prebuilt/emsdk/${PYBUILD}/lib-dynload/_ctypes.*
Expand Down Expand Up @@ -334,7 +334,7 @@ sed -i 's|-g0|-g3|g' ${MODSYSCONFIG}

# this one is required for `python3-wasm -mbuild` venv
ln ${MODSYSCONFIG} ${SDKROOT}/devices/$(arch)/usr/lib/python${PYBUILD}/

ln ${MODSYSCONFIG} ${SDKROOT}/devices/${TARGET}/usr/lib/python${PYBUILD}/

cat > ${PYTHONPYCACHEPREFIX}/.nanorc <<END
set tabsize 4
Expand Down Expand Up @@ -372,7 +372,7 @@ else
. config
. emsdk/emsdk_env.sh
popd
export PATH=$SDKROOT/emsdk/upstream/emscripten:$SDKROOT/emsdk/upstream/emscripten/system/bin:\$PATH
export PATH=$SDKROOT/${TARGET}/upstream/emscripten:$SDKROOT/${TARGET}/upstream/emscripten/system/bin:\$PATH
# export PKG_CONFIG_SYSROOT_DIR="${SDKROOT}/devices/emsdk"
export PKG_CONFIG_LIBDIR="${SDKROOT}/emsdk/upstream/emscripten/system/lib/pkgconfig"
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${HOST_PREFIX}/lib/pkgconfig"
Expand Down Expand Up @@ -405,7 +405,7 @@ export PYTHONHOME=$PREFIX
# but still can load dynload and setuptools
PYTHONPATH=${HOST_PREFIX}/lib/python\${PYBUILD}/site-packages:\$PYTHONPATH
export PYTHONPATH=${SDKROOT}/prebuilt/emsdk/\${PYBUILD}:${HOST_PREFIX}/lib/python\${PYBUILD}/lib-dynload:\$PYTHONPATH
export PYTHONPATH=${SDKROOT}/prebuilt/${TARGET}/\${PYBUILD}:${HOST_PREFIX}/lib/python\${PYBUILD}/lib-dynload:\$PYTHONPATH
# just in case
export _PYTHON_HOST_PLATFORM=${PYDK_PYTHON_HOST_PLATFORM}
Expand Down

0 comments on commit 4516d10

Please sign in to comment.