Skip to content

Commit 7d4716d

Browse files
committed
test 3.11.0b4 for 0.3.4
1 parent d6a4142 commit 7d4716d

File tree

6 files changed

+95
-68
lines changed

6 files changed

+95
-68
lines changed

config

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,47 @@
11
#!/bin/bash
22
export LC_ALL=C
3-
export ROOT=${ROOT:-/opt/python-wasm-sdk}
3+
export ROOT=$(pwd)
4+
export SDKROOT=${SDKROOT:-$ROOT}
45

56
export PYTHONDONTWRITEBYTECODE=1
67
export REBUILD=${REBUILD:-false}
78
export CI=${CI:-false}
89

9-
export HOST_PREFIX=${HOST_PREFIX:-$ROOT/devices/$(arch)/usr}
10-
export PREFIX=${PREFIX:-${ROOT}/devices/emsdk/usr}
11-
export PYTHONPYCACHEPREFIX=$(realpath ${ROOT}/build/pycache)
12-
1310
export PYMAJOR=3
14-
export HPY=$(echo -n ${HOST_PREFIX}/bin/python3.1?)
15-
export PYMINOR=$(echo $HPY|cut -d. -f2)
16-
export PIP=${HOST_PREFIX}/bin/pip3.${PYMINOR}
11+
export PYBUILD=${PYBUILD:-${PYMAJOR}.11}
12+
13+
export HOST_PREFIX=${HOST_PREFIX:-${SDKROOT}/devices/$(arch)/usr}
14+
export PREFIX=${PREFIX:-${SDKROOT}/devices/emsdk/usr}
15+
export PYTHONPYCACHEPREFIX=$(realpath ${SDKROOT}/build/pycache)
16+
1717

18-
# this is python used for emsdk
18+
# this is python used for emsdk : ${SYS_PYTHON} -> ${EMSDK_PYTHON}
1919
for py in 10 9 8 7
2020
do
21-
if command -v python3.${py} >/dev/null
21+
if command -v python${PYMAJOR}.${py} >/dev/null
2222
then
23-
export SYS_PYTHON=$(command -v python3.${py})
23+
export SYS_PYTHON=$(command -v python${PYMAJOR}.${py})
2424
break
25+
else
26+
# sane default
27+
export SYS_PYTHON=$(command -v python${PYMAJOR})
2528
fi
2629
done
2730

31+
export HPY=${HOST_PREFIX}/bin/python${PYBUILD}
32+
33+
if [ -f $HPY ]
34+
then
35+
echo -n # host python has been built successfully
36+
else
37+
export HPY=$(ls ${HOST_PREFIX}/bin/python3.?? 2>/dev/null | sort | tail -n 1)
38+
fi
39+
40+
if [ -f $HPY ]
41+
then
42+
export PYMINOR=$(echo $HPY|cut -d. -f2)
43+
export PIP=${HOST_PREFIX}/bin/pip3.${PYMINOR}
44+
fi
2845

2946
# cpython build opts
3047
export CPOPTS="-Os -g0 -fPIC"
@@ -69,3 +86,4 @@ else
6986
export PATH="${HOST_PREFIX}/bin:$PATH"
7087
export PYDK=minimal
7188
fi
89+

python-wasm-sdk.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22
reset
3+
. /etc/lsb-release
4+
export CIVER=${CIVER:-$DISTRIB_ID}
35
export SDKDIR=/opt/python-wasm-sdk
6+
export PYBUILD=3.10
7+
48

59
sudo mkdir -p ${SDKDIR}
610
sudo chmod 777 ${SDKDIR}
@@ -28,10 +32,10 @@ then
2832
# use ./ or emsdk will pollute env
2933
./scripts/emsdk-fetch.sh
3034

31-
echo " ------------------- building cpython wasm -----------------------"
35+
echo " ------------------- building cpython wasm $PYBUILD $CIVER -----------------------"
3236
if ./scripts/cpython-build-emsdk.sh > /dev/null
3337
then
34-
echo " ------------------- building cpython wasm plus -------------------"
38+
echo " ------------------- building cpython wasm plus $PYBUILD $CIVER -------------------"
3539
if ./scripts/cpython-build-emsdk-deps.sh > /dev/null
3640
then
3741
echo "making tarball"
@@ -46,11 +50,11 @@ then
4650
${SDKDIR}/emsdk \
4751
${SDKDIR}/devices/* \
4852
${SDKDIR}/prebuilt/* \
49-
> /tmp/sdk/python-wasm-sdk-${CIVER:-ubuntu-latest}.tar
50-
lz4 -c --favor-decSpeed --best /tmp/sdk/python-wasm-sdk-${CIVER:-ubuntu-latest}.tar \
51-
> /tmp/sdk/python-wasm-sdk-${CIVER:-ubuntu-latest}.tar.lz4
53+
> /tmp/sdk/python${PYBUILD}-wasm-sdk-${CIVER}.tar
54+
lz4 -c --favor-decSpeed --best /tmp/sdk/python${PYBUILD}-wasm-sdk-${CIVER}.tar \
55+
> /tmp/sdk/python${PYBUILD}-wasm-sdk-${CIVER}.tar.lz4
5256
# bzip2 will remove original
53-
bzip2 -9 /tmp/sdk/python-wasm-sdk-${CIVER:-ubuntu-latest}.tar
57+
bzip2 -9 /tmp/sdk/python${PYBUILD}-wasm-sdk-${CIVER}.tar
5458
else
5559
echo " cpython-build-emsdk-deps failed"
5660
exit 2

scripts/cpython-build-host-deps.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,26 @@ echo "
99
# python3 setup.py install --single-version-externally-managed --root=/
1010
SPY="$HPY setup.py install --single-version-externally-managed --root=/"
1111

12+
1213
# just in case
1314
$PIP install pip --upgrade
1415

15-
# to remove ctypes deps
16-
$PIP install setuptools --upgrade
17-
18-
HPFX=./devices/x86_64/usr/lib/python3.${PYMINOR}
19-
rm $HPFX/ensurepip/_bundled/setuptools-*-py3-none-any.whl
20-
mv $HPFX/site-packages/setuptool* $HPFX/
21-
mv $HPFX/site-packages/_distutils* $HPFX/
22-
mv $HPFX/site-packages/pkg_resources $HPFX/
2316

17+
if [ -d $HPFX/site-packages/setuptools ]
18+
then
19+
echo "
20+
* setuptools/_distutils/pkg_resources already migrated
21+
"
22+
else
23+
# to remove ctypes deps
24+
$PIP install setuptools --upgrade
25+
26+
HPFX=./devices/x86_64/usr/lib/python3.${PYMINOR}
27+
rm $HPFX/ensurepip/_bundled/setuptools-*-py3-none-any.whl
28+
mv $HPFX/site-packages/setuptools* $HPFX/
29+
mv $HPFX/site-packages/_distutils* $HPFX/
30+
mv $HPFX/site-packages/pkg_resources* $HPFX/
31+
fi
2432

2533

2634
export CC=clang

scripts/cpython-build-host.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mkdir -p build/cpython-host
99
if $REBUILD
1010
then
1111
echo "
12-
* building cpython
12+
* building cpython $PYBUILD $CIVER
1313
"
1414
else
1515
if [ -f ${PYTHON_FOR_BUILD} ]

scripts/cpython-fetch.sh

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@
33
. ${CONFIG:-config}
44

55
echo "
6-
*cpython-fetch*
6+
*cpython-fetch $PYBUILD*
77
"
88

99

1010
pushd src 2>&1 >/dev/null
1111

12-
1312
NOPATCH=false
13+
[ -L cpython ] && rm cpython
1414

15-
if false
15+
if echo $PYBUILD |grep -q 12$
1616
then
17-
18-
# same goal as "python-wasm/fetch-python.sh"
19-
# get python from git ( actually the only one supporting emsdk without patches)
20-
21-
if [ -d cpython ]
17+
if [ -d cpython-git ]
2218
then
23-
pushd cpython 2>&1 >/dev/null
19+
pushd cpython-git 2>&1 >/dev/null
2420
# put the tree back to original state so we can pull
2521
# Programs/python.c Modules/readline.c
2622
git restore .
@@ -35,41 +31,55 @@ then
3531
#cat $ROOT/support/compilenone.py > ./Lib/compileall.py
3632
popd
3733
else
38-
git clone https://github.com/python/cpython.git
34+
git clone --depth 1 https://github.com/python/cpython.git cpython-git
3935
export REBUILD=true
4036
fi
4137

42-
else
43-
if [ -L cpython ]
44-
then
45-
echo "
46-
* cpython source tree already linked $(file cpython)"
47-
NOPATCH=true
48-
else
49-
wget -q -c https://www.python.org/ftp/python/3.11.0/Python-3.11.0b3.tgz
50-
tar xf Python-3.11.0b3.tgz
51-
ln -s Python-3.11.0b3 cpython
52-
fi
38+
ln -s cpython-git cpython
39+
5340
fi
5441

42+
if echo $PYBUILD | grep -q 11$
43+
then
44+
#wget -q -c https://www.python.org/ftp/python/3.11.0/Python-3.11.0b3.tgz
45+
wget -q https://www.python.org/ftp/python/3.11.0/Python-3.11.0b4.tar.xz
46+
47+
#tar xf Python-3.11.0b3.tgz
48+
tar xf Python-3.11.0b4.tar.xz
49+
#ln -s Python-3.11.0b3 cpython
50+
ln -s Python-3.11.0b4 cpython
51+
export REBUILD=true
52+
fi
53+
54+
if echo $PYBUILD | grep -q 10$
55+
then
56+
tar xfj /data/git/python-wasm-sdk/src/Python-3.10.5-pydk.tar.bz2
57+
ln -s Python-3.10.5-pydk cpython
58+
NOPATCH=true
59+
export REBUILD=true
60+
fi
61+
62+
5563
popd
5664

65+
5766
if $NOPATCH
5867
then
5968
echo "
6069
* assuming cpython tree already patched, press <enter>
6170
"
62-
63-
6471
else
6572
# do some patching
6673
pushd src/cpython 2>&1 >/dev/null
6774
patch -p1 < ../../support/__EMSCRIPTEN__.embed/cpython.diff
6875
popd
6976
fi
7077

78+
7179
echo "
7280
* fetched cpython source, status is :
7381
REBUILD=${REBUILD}
7482
"
7583

84+
[ -d build/cpython-host ] && rm -rf build/cpython-host
85+
[ -d build/cpython-wasm ] && rm -rf build/cpython-wasm

scripts/emsdk-fetch.sh

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,15 @@ then
3232
* activating emsdk via emsdk_env.sh
3333
"
3434
. emsdk/emsdk_env.sh 2>&1 > /dev/null
35-
35+
# EMSDK_PYTHON may be cleared, restore it
36+
export EMSDK_PYTHON=$SYS_PYTHON
3637
else
3738
echo "
3839
ERROR cannot find emsdk/emsdk_env.sh in $(pwd)
3940
"
4041
exit 1
4142
fi
4243

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
54-
55-
56-
5744
if [ -f embuild.done ]
5845
then
5946
echo "
@@ -135,9 +122,9 @@ done
135122
136123
if \$IS_SHARED
137124
then
138-
\$SYS_PYTHON -E \$0.py $SHARED $LDFLAGS "\$@" $COMMON
125+
$EMSDK_PYTHON -E \$0.py $SHARED $LDFLAGS "\$@" $COMMON
139126
else
140-
\$SYS_PYTHON -E \$0.py $CPPFLAGS "\$@" $COMMON
127+
$EMSDK_PYTHON -E \$0.py $CPPFLAGS "\$@" $COMMON
141128
fi
142129
END
143130
cat emsdk/upstream/emscripten/emcc > emsdk/upstream/emscripten/em++
@@ -149,14 +136,14 @@ unset _PYTHON_SYSCONFIGDATA_NAME
149136
unset PYTHONHOME
150137
unset PYTHONPATH
151138
152-
\$SYS_PYTHON -E \$0.py "\$@"
139+
$EMSDK_PYTHON -E \$0.py "\$@"
153140
END
154141

155142
cat emsdk/upstream/emscripten/emar > emsdk/upstream/emscripten/emcmake
156143

157144
cat > emsdk/upstream/emscripten/emconfigure <<END
158145
#!/bin/bash
159-
\$SYS_PYTHON -E \$0.py "\$@"
146+
$EMSDK_PYTHON -E \$0.py "\$@"
160147
END
161148

162149
chmod +x emsdk/upstream/emscripten/em*

0 commit comments

Comments
 (0)