@@ -25,7 +25,7 @@ REBUILD_WASM=${REBUILD_WASMPY:-false}
2525if $REBUILD || $REBUILD_WASMPY
2626then
2727 rm -rf build/cpython-wasm/ build/pycache/config.cache
28- rm build/cpython-wasm/libpython3.?? .a 2> /dev/null
28+ rm build/cpython-wasm/libpython3.${PYMINOR} .a 2> /dev/null
2929 REBUILD=true
3030fi
3131
@@ -96,7 +96,7 @@ TESTSUITE=$TESTSUITE
9696
9797
9898
99- if [ -f build/cpython-wasm/libpython3.?? .a ]
99+ if [ -f build/cpython-wasm/libpython3.${PYMINOR} .a ]
100100then
101101 echo "
102102 * not rebuilding cpython-wasm for [$PYDK_PYTHON_HOST_PLATFORM ]
@@ -133,48 +133,54 @@ else
133133 --prefix=$PREFIX \
134134 --with-build-python=${PYTHON_FOR_BUILD} $QUIET
135135
136+ mkdir -p ${PYTHONPYCACHEPREFIX} /empty
137+ touch ${PYTHONPYCACHEPREFIX} /empty/$( $HPY -V| cut -f2 -d' ' )
138+
136139 # echo "#define HAVE_NCURSES_H" >> pyconfig.h
140+ cat > Modules/Setup.local << END
141+ *disabled*
142+ _decimal
143+ END
137144
138- if EMCC_CFLAGS=" -sUSE_ZLIB -sUSE_BZIP2" eval emmake make -j$( nproc) $QUIET
145+ if EMCC_CFLAGS=" -sUSE_ZLIB -sUSE_BZIP2" \
146+ emmake make -j$( nproc) WASM_ASSETS_DIR=$( realpath ${PYTHONPYCACHEPREFIX} /empty) @/
139147 then
140- EMCC_CFLAGS=" -sUSE_ZLIB -sUSE_BZIP2" eval emmake make install $QUIET
148+ EMCC_CFLAGS=" -sUSE_ZLIB -sUSE_BZIP2" \
149+ emmake make WASM_ASSETS_DIR=$( realpath ${PYTHONPYCACHEPREFIX} /empty) @/ install
141150 else
142- echo " **** cpython wasm build failed *** "
151+ echo " **** cpython wasm build failed ***
152+
153+ EMCC_CFLAGS=" -sUSE_ZLIB -sUSE_BZIP2" emmake make WASM_ASSETS_DIR=$( realpath ${PYTHONPYCACHEPREFIX} /empty) @/ install
154+
155+ " 1>&2
156+
143157 exit 1
144158 fi
145159
146- rm -rf $( find $ROOT /devices/ -type d| grep __pycache__$)
160+ rm -rf $( find $ROOT /devices/ -type d| grep / __pycache__$)
147161
148162 popd
149163
150164 mkdir -p ${ROOT} /prebuilt/emsdk
151165
152166 # move them to MEMFS
153- mv $PREFIX /lib/python3.?? /lib-dynload/* $ROOT /prebuilt/emsdk/site-packages
167+ mv $PREFIX /lib/python3.${PYMINOR} /lib-dynload/* $ROOT /prebuilt/emsdk/site-packages
154168
155169 # specific platform support
156- cp -Rfv $ROOT /support/__EMSCRIPTEN__.patches/. $HOST_PREFIX /lib/python3.?? /
157-
158- # TODO: use PYTHONPATH for python3-wasm to pick them in devices/emsdk/usr/lib/python3.11/
159- # ln $PREFIX/lib/python3.??/_sysconfigdata__emscripten_wasm32-emscripten.py devices/x86_64/usr/lib/python3.??/
160-
170+ cp -Rfv $ROOT /support/__EMSCRIPTEN__.patches/3.${PYMINOR} /. $HOST_PREFIX /lib/python3.${PYMINOR} /
161171
162172 cp -vf build/cpython-wasm/libpython3.* .a prebuilt/emsdk/
163- rmdir $PREFIX /lib/python3.?? /lib-dynload
173+ rmdir $PREFIX /lib/python3.${PYMINOR} /lib-dynload
164174fi
165175
166176mkdir -p $PYTHONPYCACHEPREFIX /sysconfig
167177
168178
169179# FIXME: seems CI cannot locate that one with python3-wasm
170- cp $PREFIX /lib/python3.?? /_sysconfigdata__emscripten_wasm32-emscripten.py $PYTHONPYCACHEPREFIX /sysconfig/_sysconfigdata__emscripten_debug.py
180+ cp $PREFIX /lib/python3.${PYMINOR} /_sysconfigdata__emscripten_wasm32-emscripten.py $PYTHONPYCACHEPREFIX /sysconfig/_sysconfigdata__emscripten_debug.py
171181sed -i ' s|-Os|-O0|g' $PYTHONPYCACHEPREFIX /sysconfig/_sysconfigdata__emscripten_debug.py
172182sed -i ' s|-g0|-g3|g' $PYTHONPYCACHEPREFIX /sysconfig/_sysconfigdata__emscripten_debug.py
173183
174- # workaround
175- # cp $PYTHONPYCACHEPREFIX/sysconfig/_sysconfigdata__emscripten_debug.py devices/x86_64/usr/lib/python3.11/_sysconfigdata__emscripten_debug.py
176-
177-
178184
179185# python setup.py install --single-version-externally-managed --root=/
180186# pip3 install .
@@ -281,8 +287,8 @@ export PYTHONHOME=$PREFIX
281287
282288# find sysconfig ( tweaked )
283289# but still can load dynload and setuptools
284- PYTHONPATH=$( echo -n ${HOST_PREFIX} /lib/python3.?? /site-packages) :\$ PYTHONPATH
285- export PYTHONPATH=$PYTHONPYCACHEPREFIX /sysconfig:$( echo -n ${HOST_PREFIX} /lib/python3.?? /lib-dynload) :\$ PYTHONPATH
290+ PYTHONPATH=$( echo -n ${HOST_PREFIX} /lib/python3.${PYMINOR} /site-packages) :\$ PYTHONPATH
291+ export PYTHONPATH=$PYTHONPYCACHEPREFIX /sysconfig:$( echo -n ${HOST_PREFIX} /lib/python3.${PYMINOR} /lib-dynload) :\$ PYTHONPATH
286292
287293
288294#probably useless
0 commit comments