Skip to content

Commit 2d548e2

Browse files
committed
add 3.13
1 parent 7a9e117 commit 2d548e2

File tree

9 files changed

+178
-132
lines changed

9 files changed

+178
-132
lines changed
443 KB
Binary file not shown.

python-wasi-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ORIGIN=$(pwd)
3232

3333
# 3.12 3.11 3.10
3434

35-
BUILDS=${BUILDS:-3.11 3.12}
35+
BUILDS=${BUILDS:-3.11 3.12 3.13}
3636

3737
for PYBUILD in $BUILDS
3838
do

python-wasm-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ORIGIN=$(pwd)
3232

3333
# 3.12 3.11 3.10
3434

35-
BUILDS=${BUILDS:-3.11 3.12}
35+
BUILDS=${BUILDS:-3.11 3.12 3.13}
3636

3737
for PYBUILD in $BUILDS
3838
do

scripts/cpython-build-emsdk-prebuilt.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
. ${CONFIG:-config}
44

5-
CYTHON_REL=${CYTHON_REL:-3.0.6}
5+
CYTHON_REL=${CYTHON_REL:-3.0.8}
66
CYTHON_WHL=${CYTHON:-Cython-${CYTHON_REL}-py2.py3-none-any.whl}
77

88
# all needed for PEP722/723
9-
PACKAGING="pip build wheel pyparsing packaging installer"
9+
PACKAGING="pip build wheel pyparsing packaging PATCHES/installer-1.0.0.dev0-py3-none-any.whl"
1010

1111
$HPIP install --upgrade $PACKAGING
1212

scripts/cpython-build-host.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ END
8585
8686
END
8787

88-
if echo $PYBUILD|grep -q 3.12$
88+
if echo $PYBUILD|grep -q 3.13$
8989
then
9090
# Prevent freezing bytecode with a different magic
9191
rm -f $HOST_PREFIX/bin/python3 $HOST_PREFIX/bin/python${PYBUILD}

scripts/cpython-build-wasisdk.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
3+
. ${CONFIG:-config}
4+
5+
6+
export PREFIX=${PREFIX:-${SDKROOT}/devices/wasisdk/usr}
7+
export PYTHON_FOR_BUILD=${PYTHON_FOR_BUILD:-${HPY}}
8+
9+
10+
echo "
11+
* building cpython-wasi ${PREFIX}/bin/python${PYBUILD}.wasm
12+
with PYTHON_FOR_BUILD=$PYTHON_FOR_BUILD
13+
" 1>&2
14+
15+
16+
17+
18+
if [ -f ${PYTHON_FOR_BUILD} ]
19+
then
20+
echo found PYTHON_FOR_BUILD=${PYTHON_FOR_BUILD}
21+
else
22+
mkdir -p ${SDKROOT}/build/cpython-host
23+
pushd ${SDKROOT}/build/cpython-host
24+
CC=clang CXX=clang++ ../../src/cpython${PYBUILD}/configure --prefix=${SDKROOT}/devices/x86_64/usr
25+
make && make install
26+
popd
27+
fi
28+
29+
. ${SDKROOT}/scripts/wasisdk-fetch.sh
30+
31+
32+
33+
34+
export LD_LIBRARY_PATH=${SDKROOT}/devices/x86_64/usr/lib:$LD_LIBRARY_PATH
35+
36+
if [ -f $PYTHON_FOR_BUILD ]
37+
then
38+
39+
PYSRC=${SDKROOT}/src/cpython${PYBUILD}
40+
41+
echo " * building python wasi from ${PYSRC}"
42+
43+
mkdir -p ${SDKROOT}/build/cpython-wasi
44+
45+
export PLATFORM_TRIPLET=wasm32-unknown-wasi
46+
cat $PYSRC/Tools/wasm/config.site-wasm32-wasi > $PYSRC/Tools/wasm/config.site-wasm32-wasisdk
47+
cat >> $PYSRC/Tools/wasm/config.site-wasm32-wasisdk <<END
48+
ac_cv_func_clock_gettime=yes
49+
ac_cv_func_clock=yes
50+
ac_cv_func_timegm=yes
51+
ac_cv_cc_name=clang
52+
cross_compiling=yes
53+
END
54+
55+
pushd ${SDKROOT}/build/cpython-wasi
56+
sed -i 's| -Wl,--stack-first -Wl,--initial-memory=10485760||g' $PYSRC/configure.ac
57+
sed -i 's| -Wl,--stack-first -Wl,--initial-memory=10485760||g' $PYSRC/configure
58+
59+
LDSHARED="${SDKROOT}/wasisdk/upstream/bin/wasm-ld --no-entry" CONFIG_SITE=$PYSRC/Tools/wasm/config.site-wasm32-wasisdk \
60+
$PYSRC/configure -C \
61+
--with-c-locale-coercion --without-pymalloc --disable-ipv6 --with-ensurepip=no \
62+
--prefix=${PREFIX} \
63+
--host=wasm32-unknown-wasi --with-suffix=.wasm \
64+
--build=$($PYSRC/config.guess) \
65+
--with-build-python=$PYTHON_FOR_BUILD
66+
67+
cat <<END >>pyconfig.h
68+
#ifdef HAVE_MEMFD_CREATE
69+
#undef HAVE_MEMFD_CREATE
70+
#endif
71+
72+
#ifdef HAVE_PTHREAD_H
73+
#undef HAVE_PTHREAD_H
74+
#endif
75+
76+
//#define HAVE_CLOCK
77+
//#define HAVE_CLOCK_GETTIME
78+
//#define HAVE_TIMEGM
79+
END
80+
81+
make platform
82+
83+
if make && make install
84+
then
85+
echo done
86+
# cat > ${SDKROOT}/bin/python3 <<END
87+
##!/bin/bash
88+
#wasmtime --dir=/ --dir=. ${SDKROOT}/bin/python3.wasm \$@
89+
#END
90+
# chmod +x ${SDKROOT}/bin/python3
91+
# ln ${SDKROOT}/bin/python3 ${SDKROOT}/bin/python
92+
fi
93+
popd
94+
95+
else
96+
echo cannot find PYTHON_FOR_BUILD=$PYTHON_FOR_BUILD
97+
fi
98+

scripts/cpython-fetch.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,6 @@ fi
4545

4646
if echo $PYBUILD |grep -q 12$
4747
then
48-
# if [ -d cpython${PYBUILD} ]
49-
# then
50-
# pushd cpython${PYBUILD} 2>&1 >/dev/null
51-
# # put the tree back to original state so we can pull
52-
# # Programs/python.c Modules/readline.c
53-
# git restore .
54-
55-
# if git pull|grep -q 'Already up to date'
56-
# then
57-
# export REBUILD=${REBUILD:-false}
58-
# else
59-
# export REBUILD=true
60-
# fi
61-
# #not here or pip won't install properly anymore its wheels
62-
# #cat $ROOT/support/compilenone.py > ./Lib/compileall.py
63-
# popd
64-
# else
65-
# git clone --no-tags --depth 1 --single-branch --branch 3.12 https://github.com/python/cpython.git cpython${PYBUILD}
66-
# export REBUILD=true
67-
# fi
68-
6948
wget -q -c https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tar.xz
7049
tar xf Python-3.12.1.tar.xz
7150
ln -s Python-3.12.1 cpython${PYBUILD}

scripts/make-shells.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
CPU=${CPU:-wasm32}
3+
TARGET=${TARGET:-emsdk}
4+
5+
cat > $ROOT/${PYDK_PYTHON_HOST_PLATFORM}-shell.sh <<END
6+
#!/bin/bash
7+
export ROOT=${SDKROOT}
8+
export SDKROOT=${SDKROOT}
9+
10+
export PYBUILD=\${PYBUILD:-$PYBUILD}
11+
export PYMAJOR=\$(echo -n \$PYBUILD|cut -d. -f1)
12+
export PYMINOR=\$(echo -n \$PYBUILD|cut -d. -f2)
13+
14+
export CARGO_HOME=\${CARGO_HOME:-${SDKROOT}}/rust
15+
export RUSTUP_HOME=\${RUSTUP_HOME:-${SDKROOT}}/rust
16+
mkdir -p \${CARGO_HOME}/bin
17+
export PATH=\${CARGO_HOME}/bin:\$PATH
18+
19+
export PANDA_PRC_DIR=${SDKROOT}/support
20+
21+
22+
export PATH=${HOST_PREFIX}/bin:\$PATH:${SDKROOT}/devices/${TARGET}/usr/bin:${SDKROOT}/emsdk/node/16.20.0_64bit/bin
23+
export LD_LIBRARY_PATH=${HOST_PREFIX}/lib:${LD_LIBRARY_PATH}
24+
25+
export PLATFORM_TRIPLET=${PYDK_PYTHON_HOST_PLATFORM}
26+
export PREFIX=$PREFIX
27+
export PYTHONPYCACHEPREFIX=${PYTHONPYCACHEPREFIX:-${SDKROOT}/build/pycache}
28+
mkdir -p \$PYTHONPYCACHEPREFIX
29+
30+
# so pip does not think everything in ~/.local is useable
31+
export HOME=${SDKROOT}
32+
33+
export PYTHONDONTWRITEBYTECODE=1
34+
35+
END
36+
37+
Lines changed: 38 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,40 @@
1-
diff --git a/Programs/python.c b/Programs/python.c
2-
index 84148f7..348207e 100644
3-
--- a/Programs/python.c
4-
+++ b/Programs/python.c
5-
@@ -2,16 +2,72 @@
6-
7-
#include "Python.h"
8-
9-
-#ifdef MS_WINDOWS
10-
-int
11-
-wmain(int argc, wchar_t **argv)
12-
+#if __PYDK__
13-
+#include "pycore_call.h" // _PyObject_CallNoArgs()
14-
+#include "pycore_initconfig.h" // _PyArgv
15-
+#include "pycore_interp.h" // _PyInterpreterState.sysdict
16-
+#include "pycore_pathconfig.h" // _PyPathConfig_ComputeSysPath0()
17-
+#include "pycore_pylifecycle.h" // _Py_PreInitializeFromPyArgv()
18-
+#include "pycore_pystate.h" // _PyInterpreterState_GET()
19-
+
20-
+static PyStatus
21-
+pymain_init(const _PyArgv *args)
22-
+{
23-
+ PyStatus status;
24-
+
25-
+ status = _PyRuntime_Initialize();
26-
+ if (_PyStatus_EXCEPTION(status)) {
27-
+ return status;
28-
+ }
29-
+
30-
+ PyPreConfig preconfig;
31-
+ PyPreConfig_InitPythonConfig(&preconfig);
32-
+
33-
+ status = _Py_PreInitializeFromPyArgv(&preconfig, args);
34-
+ if (_PyStatus_EXCEPTION(status)) {
35-
+ return status;
36-
+ }
37-
+
38-
+ PyConfig config;
39-
+ PyConfig_InitPythonConfig(&config);
40-
+
41-
+ if (args->use_bytes_argv) {
42-
+ status = PyConfig_SetBytesArgv(&config, args->argc, args->bytes_argv);
43-
+ }
44-
+ else {
45-
+ status = PyConfig_SetArgv(&config, args->argc, args->wchar_argv);
46-
+ }
47-
+ if (_PyStatus_EXCEPTION(status)) {
48-
+ goto done;
49-
+ }
50-
+
51-
+ status = Py_InitializeFromConfig(&config);
52-
+ if (_PyStatus_EXCEPTION(status)) {
53-
+ goto done;
54-
+ }
55-
+ status = _PyStatus_OK();
56-
+
57-
+done:
58-
+ PyConfig_Clear(&config);
59-
+ return status;
60-
+}
61-
+
62-
+static void
63-
+pymain_free(void)
64-
{
65-
- return Py_Main(argc, argv);
66-
+ _PyImport_Fini2();
67-
+ _PyPathConfig_ClearGlobal();
68-
+ _Py_ClearStandardStreamEncoding();
69-
+ _Py_ClearArgcArgv();
70-
+ _PyRuntime_Finalize();
1+
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
2+
index c2de4ec..0bae03c 100644
3+
--- a/Python/sysmodule.c
4+
+++ b/Python/sysmodule.c
5+
@@ -55,7 +55,7 @@ extern void *PyWin_DLLhModule;
6+
extern const char *PyWin_DLLVersionString;
7+
#endif
8+
9+
-#ifdef __EMSCRIPTEN__
10+
+#if 0
11+
# include <emscripten.h>
12+
#endif
13+
14+
@@ -3222,7 +3222,7 @@ make_impl_info(PyObject *version_info)
15+
return NULL;
7116
}
72-
+
73-
+#include "/opt/python-wasm-sdk/support/__EMSCRIPTEN__.c"
74-
#else
75-
int
76-
main(int argc, char **argv)
77-
{
78-
+
79-
return Py_BytesMain(argc, argv);
80-
}
81-
-#endif
82-
+#endif //#if __PYDK__
83-
diff --git a/configure b/configure
84-
index 0e5f3f6..5cf6451 100755
85-
--- a/configure
86-
+++ b/configure
87-
@@ -9179,7 +9179,7 @@ fi
88-
89-
as_fn_append LDFLAGS_NODIST " -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520"
90-
91-
- as_fn_append LDFLAGS_NODIST " -sWASM_BIGINT"
92-
+ as_fn_append LDFLAGS_NODIST " "
93-
94-
as_fn_append LDFLAGS_NODIST " -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"
95-
96-
diff --git a/configure.ac b/configure.ac
97-
index 4938681..ecad731 100644
98-
--- a/configure.ac
99-
+++ b/configure.ac
100-
@@ -2103,7 +2103,7 @@ AS_CASE([$ac_sys_system],
101-
AS_VAR_APPEND([LDFLAGS_NODIST], [" -sALLOW_MEMORY_GROWTH -sTOTAL_MEMORY=20971520"])
102-
103-
dnl map int64_t and uint64_t to JS bigint
104-
- AS_VAR_APPEND([LDFLAGS_NODIST], [" -sWASM_BIGINT"])
105-
+ AS_VAR_APPEND([LDFLAGS_NODIST], [" "])
10617

107-
dnl Include file system support
108-
AS_VAR_APPEND([LDFLAGS_NODIST], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
18+
-#ifdef __EMSCRIPTEN__
19+
+#if 0
20+
21+
PyDoc_STRVAR(emscripten_info__doc__,
22+
"sys._emscripten_info\n\
23+
@@ -3454,7 +3454,7 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
24+
goto type_init_failed;
25+
}
26+
27+
-#ifdef __EMSCRIPTEN__
28+
+#if 0
29+
if (EmscriptenInfoType == NULL) {
30+
EmscriptenInfoType = PyStructSequence_NewType(&emscripten_info_desc);
31+
if (EmscriptenInfoType == NULL) {
32+
@@ -3734,7 +3734,7 @@ _PySys_FiniTypes(PyInterpreterState *interp)
33+
#endif
34+
_PyStructSequence_FiniBuiltin(interp, &Hash_InfoType);
35+
_PyStructSequence_FiniBuiltin(interp, &AsyncGenHooksType);
36+
-#ifdef __EMSCRIPTEN__
37+
+#if 0
38+
if (_Py_IsMainInterpreter(interp)) {
39+
Py_CLEAR(EmscriptenInfoType);
40+
}

0 commit comments

Comments
 (0)