@@ -56,12 +56,14 @@ emscripten () {
56
56
cd emscripten/
57
57
# OPT=-Oz: TODO
58
58
# CONFIG_SITE: deals with cross-compilation https://bugs.python.org/msg136962
59
+ # PATH: detect our Python, beware of conflict with emcc's python3
60
+ # don't use PYTHON_FOR_BUILD which is high-level / lots of options
59
61
# --without-pymalloc: ?
60
62
# --disable-ipv6: ?
61
- # --disable-shared: compile statically for Emscripten perfs + incomplete PIC support
63
+ # --disable-shared: compile statically for Emscripten perfs + incomplete PIC support
62
64
if [ ! -e config.status ]; then
63
65
CONFIG_SITE=../config-emscripten.site BASECFLAGS=' -s USE_ZLIB=1' READELF=true \
64
- PYTHON_FOR_BUILD =$BUILD /Python-$VERSION /native/python \
66
+ PATH =$BUILD /Python-$VERSION /native: $PATH \
65
67
emconfigure ../configure \
66
68
--host=asmjs-unknown-emscripten --build=$( ../config.guess) \
67
69
--prefix=' ' \
84
86
# decrease .pyo size by dropping docstrings
85
87
sed -i -e ' /compileall.py/ s/ -O / -OO /' Makefile
86
88
87
- # Trigger setup.py:CROSS_COMPILING (introduced in 3.8)
88
- export _PYTHON_HOST_PLATFORM=emscripten
89
-
90
- emmake make -j$( nproc)
91
- emmake make install DESTDIR=$DESTDIR
89
+ (
90
+ export PATH=$BUILD /Python-$VERSION /native:$PATH
91
+ # Trigger setup.py:CROSS_COMPILING (introduced in 3.8)
92
+ export _PYTHON_HOST_PLATFORM=emscripten
93
+ emmake make -j$( nproc)
94
+ emmake make install DESTDIR=$DESTDIR
95
+ )
92
96
93
97
# Basic trimming
94
98
# Disabled for now, better cherry-pick the files we need
@@ -166,14 +170,14 @@ crosspython () {
166
170
# Use Python.h configured for WASM
167
171
ln -s $DESTDIR /include include
168
172
169
- # TODO: Use compiler settings configured for WASM
170
- # rm lib/python3.8/_sysconfigdata.*
171
- # cp -a $DESTDIR/ lib/python3.8/_sysconfigdata.* lib/python3.8/
173
+ # Use compiler settings configured for WASM
174
+ cp -a $DESTDIR / lib/python3.8/_sysconfigdata__emscripten_.py \
175
+ lib/python3.8/_sysconfigdata_ * .py
172
176
)
173
177
done
174
- # TODO: 'CCSHARED': 'xxx',
175
- # sed -i -e "s/'CCSHARED': .*/'CCSHARED': '-fPIC -s SIDE_MODULE=1',/" \
176
- # crosspython-dynamic/lib/python3.8/_sysconfigdata .py
178
+ # 'CCSHARED': 'xxx',
179
+ sed -i -e " s/'CCSHARED': .*/'CCSHARED': '-fPIC -s SIDE_MODULE=1',/" \
180
+ crosspython-dynamic/lib/python3.8/_sysconfigdata_ * .py
177
181
}
178
182
179
183
case " $1 " in
@@ -187,7 +191,7 @@ case "$1" in
187
191
crosspython
188
192
;;
189
193
* )
190
- echo " Usage: $0 unpack|native |emscripten"
194
+ echo " Usage: $0 unpack|hostpython |emscripten|mock|crosspython "
191
195
exit 1
192
196
;;
193
197
esac
0 commit comments