Skip to content

Commit c0f89a0

Browse files
committed
0.0.9
1 parent c8db4f0 commit c0f89a0

File tree

4 files changed

+83
-69
lines changed

4 files changed

+83
-69
lines changed

scripts/cpython-build-emsdk.sh

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,19 @@ else
147147

148148
popd
149149

150+
mkdir -p ${ROOT}/prebuilt/emsdk
151+
150152
# move them to MEMFS
151-
mv $PREFIX/lib/python3.??/lib-dynload/* $ROOT/support/__EMSCRIPTEN__/
153+
mv $PREFIX/lib/python3.??/lib-dynload/* $ROOT/prebuilt/emsdk/site-packages
152154

153155
# specific platform support
154156
cp -Rfv $ROOT/support/__EMSCRIPTEN__.patches/. $HOST_PREFIX/lib/python3.??/
155157

156158
# TODO: use PYTHONPATH for python3-wasm to pick them in devices/emsdk/usr/lib/python3.11/
157159
#ln $PREFIX/lib/python3.??/_sysconfigdata__emscripten_wasm32-emscripten.py devices/x86_64/usr/lib/python3.??/
158160

159-
mkdir -p prebuilt
160-
cp -vf build/cpython-wasm/libpython3.*.a prebuilt/
161+
162+
cp -vf build/cpython-wasm/libpython3.*.a prebuilt/emsdk/
161163
rmdir $PREFIX/lib/python3.??/lib-dynload
162164
fi
163165

@@ -182,49 +184,45 @@ cat > $HOST_PREFIX/bin/cc <<END
182184
unset _PYTHON_SYSCONFIGDATA_NAME
183185
unset PYTHONHOME
184186
unset PYTHONPATH
185-
for py in 10 9 8 7
186-
do
187-
if command -v python3.${py}
188-
then
189-
export EMSDK_PYTHON=$(command -v python3.${py})
190-
break
191-
fi
192-
done
187+
188+
SHARED="-Wno-unused-command-line-argument"
189+
IS_SHARED=false
193190
194191
for arg do
195192
shift
193+
194+
# that is for some very bad setup.py behaviour regarding cross compiling. should not be needed ..
196195
[ "\$arg" = "-I/usr/include" ] && continue
197196
[ "\$arg" = "-I/usr/include/SDL2" ] && continue
198197
[ "\$arg" = "-L/usr/lib64" ] && continue
199198
[ "\$arg" = "-L/usr/lib" ] && continue
200-
set -- "\$@" "\$arg"
201-
done
202199
203-
SHARED=""
204-
IS_SHARED=false
200+
if [ "\$arg" = "-shared" ]
201+
then
202+
IS_SHARED=true
203+
SHARED="$SHARED -sSIDE_MODULE"
204+
fi
205205
206-
if echo \$@|grep -q shared
207-
then
208-
IS_SHARED=true
209-
SHARED="-sSIDE_MODULE"
210-
else
211-
if echo \$@|grep -q wasm32-emscripten.so
206+
if echo "\$arg"|grep -q wasm32-emscripten.so\$
212207
then
213208
IS_SHARED=true
214-
SHARED="-shared -sSIDE_MODULE"
209+
SHARED="$SHARED -shared -sSIDE_MODULE"
215210
fi
216-
fi
211+
set -- "\$@" "\$arg"
212+
done
213+
217214
218215
if \$IS_SHARED
219216
then
220-
# $COPTS
221-
emcc \$SHARED $COPTS $LDFLAGS -sSIDE_MODULE -gsource-map --source-map-base / \$@
217+
$SYS_PYTHON -E $EMSDK/upstream/emscripten/emcc.py \
218+
\$SHARED $COPTS $LDFLAGS -sSIDE_MODULE -gsource-map --source-map-base / \$@
222219
else
223-
# $COPTS
224-
emcc $COPTS $CPPFLAGS -DBUILD_STATIC \$@
220+
$SYS_PYTHON -E $EMSDK/upstream/emscripten/emcc.py \
221+
$COPTS $CPPFLAGS -DBUILD_STATIC \$@
225222
fi
226223
END
227224

225+
228226
chmod +x $HOST_PREFIX/bin/cc
229227

230228
cat > ${PYTHONPYCACHEPREFIX}/.nanorc <<END

scripts/cpython-build-host-deps.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
. ${CONFIG:-config}
22

33
echo "
4-
*cpython-build-host-deps*
4+
*cpython-build-host-deps pip==$PIP *
55
" 1>&2
66

77

88
# https://stackoverflow.com/questions/6301003/stopping-setup-py-from-installing-as-egg
99
# python3 setup.py install --single-version-externally-managed --root=/
10+
SPY="$HPY setup.py install --single-version-externally-managed --root=/"
1011

1112
# just in case
1213
$PIP install pip --upgrade
@@ -81,16 +82,16 @@ pushd cffi-branch-default
8182
popd
8283

8384

84-
# cython 3 ( not out yet )
85-
if $HPY -m cython -V 2>&1|grep -q 'version 3.0.'
86-
then
87-
echo found cython 3+
88-
else
89-
git_update https://github.com/cython/cython
90-
pushd cython
91-
$PIP install .
92-
popd
93-
fi
85+
## cython 3 ( not out yet )
86+
#if $HPY -m cython -V 2>&1|grep -q 'version 3.0.'
87+
#then
88+
# echo found cython 3+
89+
#else
90+
# git_update https://github.com/cython/cython
91+
# pushd cython
92+
# $PIP install .
93+
# popd
94+
#fi
9495

9596

9697
if [ -d pymunk-4.0.0 ]
@@ -100,8 +101,8 @@ then
100101
[ -d $HOST_PREFIX/lib/python3.11/site-packages/pymunk4 ] && rm -rf $HOST_PREFIX/lib/python3.11/site-packages/pymunk4
101102
rm -f build/lib/pymunk/* chipmunk_src/*.so chipmunk_src/*/*.o
102103
$HPY setup.py build_chipmunk
103-
$HPY setup.py install
104-
mv pymunk/libchipmunk.so $HOST_PREFIX/lib/python3.11/site-packages/pymunk/libchipmunk64.so
104+
$SPY
105+
mv $HOST_PREFIX/lib/python3.11/site-packages/pymunk/libchipmunk.so $HOST_PREFIX/lib/python3.11/site-packages/pymunk/libchipmunk64.so
105106
mv $HOST_PREFIX/lib/python3.11/site-packages/pymunk $HOST_PREFIX/lib/python3.11/site-packages/pymunk4
106107
popd
107108
fi

scripts/cpython-build-host.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else
1515
if [ -f ${PYTHON_FOR_BUILD} ]
1616
then
1717
REBUILD=false
18-
echo " * will *RE-USE* PYTHON_FOR_BUILD found at ${PYTHON_FOR_BUILD}"
18+
echo " * will *RE-USE* PYTHON_FOR_BUILD found at ${PYTHON_FOR_BUILD}" 1>&2
1919
else
2020
REBUILD=true
2121
fi
@@ -31,7 +31,7 @@ then
3131

3232

3333
#export OPT="$CPOPTS -DNDEBUG -fwrapv"
34-
cat $ROOT/src/cpython/Tools/wasm/config.host-wasm32-emscripten <<END
34+
cat > $ROOT/src/cpython/Tools/wasm/config.host-wasm32-emscripten <<END
3535
ac_cv_lib_intl_textdomain=no
3636
ac_cv_func_bind_textdomain_codeset=no
3737
END
@@ -45,10 +45,12 @@ END
4545

4646
cat >> pyconfig.h <<END
4747
#ifdef HAVE_LIBINTL_H
48+
#warning "HAVE_LIBINTL_H but We do not want to link to libintl"
4849
#undef HAVE_LIBINTL_H
4950
#endif
5051
5152
#ifdef WITH_LIBINTL
53+
#warning "WITH_LIBINTL but We do not want to link to libintl"
5254
#undef WITH_LIBINTL
5355
#endif
5456
@@ -59,20 +61,20 @@ END
5961
# Prevent freezing bytecode with a different magic
6062
rm -f $HOST_PREFIX/bin/python3*
6163

62-
if which python3.11|grep -q python
64+
if command -v python3.11
6365
then
6466
echo "
6567
66-
6768
===================================================================================
6869
69-
it's not safe to have a python3.11 in the path while in pre-release cycle
70-
_sre.MAGIC / bytecode weird errors etc ...
70+
it's not safe to have a python3.11 in the path :
71+
$(command -v python3.11)
72+
while in pre-release cycle : _sre.MAGIC / bytecode weird errors etc ...
7173
7274
===================================================================================
7375
74-
"
75-
sleep 3
76+
" 1>&2
77+
sleep 6
7678
fi
7779

7880
# OPT="$OPT"
@@ -96,7 +98,7 @@ END
9698
9799
reminder: you need clang libffi-dev and usual cpython requirements.
98100
==========================================================================
99-
"
101+
" 1>&2
100102
exit 1
101103
fi
102104

@@ -108,7 +110,7 @@ else
108110
109111
* cpython host already built :
110112
PYTHON_FOR_BUILD=${PYTHON_FOR_BUILD}
111-
"
113+
" 1>&2
112114
fi
113115

114116

scripts/emsdk-fetch.sh

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ then
4040
exit 1
4141
fi
4242

43-
# 3.6 could have problems
44-
for py in 10 9 8 7
45-
do
46-
if command -v python3.${py} >/dev/null
47-
then
48-
export EMSDK_PYTHON=$(command -v python3.${py})
49-
break
50-
fi
51-
done
43+
# EMSDK_PYTHON is cleared
44+
# https://github.com/emscripten-core/emscripten/pull/16736
45+
# # 3.6 could have problems
46+
# for py in 10 9 8 7
47+
# do
48+
# if command -v python3.${py} >/dev/null
49+
# then
50+
# export EMSDK_PYTHON=$(command -v python3.${py})
51+
# break
52+
# fi
53+
# done
5254

5355

5456

@@ -92,23 +94,34 @@ unset PYTHONPATH
9294
SHARED=""
9395
IS_SHARED=false
9496
95-
if echo "\$@"|grep -q shared
96-
then
97-
IS_SHARED=true
98-
SHARED="-sSIDE_MODULE"
99-
else
100-
if echo "\$@"|grep -q wasm32-emscripten.so
97+
for arg do
98+
shift
99+
100+
# that is for some very bad setup.py behaviour regarding cross compiling. should not be needed ..
101+
[ "\$arg" = "-I/usr/include" ] && continue
102+
[ "\$arg" = "-I/usr/include/SDL2" ] && continue
103+
[ "\$arg" = "-L/usr/lib64" ] && continue
104+
[ "\$arg" = "-L/usr/lib" ] && continue
105+
106+
if [ "\$arg" = "-shared" ]
101107
then
102108
IS_SHARED=true
103-
SHARED="-shared -sSIDE_MODULE"
109+
SHARED="$SHARED -sSIDE_MODULE"
104110
fi
105-
fi
111+
112+
if echo "\$arg"|grep -q wasm32-emscripten.so\$
113+
then
114+
IS_SHARED=true
115+
SHARED="$SHARED -shared -sSIDE_MODULE"
116+
fi
117+
set -- "\$@" "\$arg"
118+
done
106119
107120
if \$IS_SHARED
108121
then
109-
\$SYS_PYTHON -E \$0.py $SHARED $LDFLAGS -Wno-unused-command-line-argument "\$@"
122+
\$SYS_PYTHON -E \$0.py $SHARED $LDFLAGS "\$@"
110123
else
111-
\$SYS_PYTHON -E \$0.py $CPPFLAGS -Wno-unused-command-line-argument "\$@"
124+
\$SYS_PYTHON -E \$0.py $CPPFLAGS "\$@"
112125
fi
113126
END
114127
cat emsdk/upstream/emscripten/emcc > emsdk/upstream/emscripten/em++

0 commit comments

Comments
 (0)