Skip to content

Commit 73ee3be

Browse files
committed
3.1.47pre
1 parent 52f98f6 commit 73ee3be

File tree

10 files changed

+1943
-50
lines changed

10 files changed

+1943
-50
lines changed

python-wasm-sdk.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ do
5252
cd ${SDKROOT}
5353
. support/__EMSCRIPTEN__.sh
5454

55-
. scripts/cpython-build-host.sh 2>&1 >/dev/null
55+
. scripts/cpython-build-host.sh #2>&1 >/dev/null
5656

5757
. scripts/cpython-build-host-deps.sh
5858
# >/dev/null
5959

60+
# cool down machine a bit
6061
[ -f /lowend ] && sleep 45
6162

63+
cd ${SDKROOT}
6264
# use ./ or emsdk will pollute env
6365
./scripts/emsdk-fetch.sh
6466

scripts/cpython-build-emsdk.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,19 @@ END
240240

241241
if pushd ${SDKROOT}/build/cpython-wasm
242242
then
243-
mkdir -p ${SDKROOT}/prebuilt/emsdk
244-
OBJDIR=$(echo -n build/temp.emscripten-wasm32-${PYBUILD}/opt/python-wasm-sdk/src/Python-3.*)
245-
OBJS="${OBJDIR}/Modules/_ctypes/_ctypes.o \
246-
${OBJDIR}/Modules/_ctypes/callbacks.o \
247-
${OBJDIR}/Modules/_ctypes/callproc.o \
248-
${OBJDIR}/Modules/_ctypes/cfield.o \
249-
${OBJDIR}/Modules/_ctypes/stgdict.o"
243+
if echo $PYBUILD|grep -q 11$
244+
then
245+
mkdir -p ${SDKROOT}/prebuilt/emsdk
246+
OBJDIR=$(echo -n build/temp.emscripten-wasm32-${PYBUILD}/opt/python-wasm-sdk/src/Python-3.*)
247+
OBJS="${OBJDIR}/Modules/_ctypes/_ctypes.o \
248+
${OBJDIR}/Modules/_ctypes/callbacks.o \
249+
${OBJDIR}/Modules/_ctypes/callproc.o \
250+
${OBJDIR}/Modules/_ctypes/cfield.o \
251+
${OBJDIR}/Modules/_ctypes/stgdict.o"
252+
else
253+
# 3.12+
254+
OBJS=$(find $(pwd)/Modules/_ctypes|grep o$)
255+
fi
250256

251257
$SDKROOT/emsdk/upstream/emscripten/emar rcs ${SDKROOT}/prebuilt/emsdk/lib_ctypes${PYBUILD}.a $OBJS
252258
popd

scripts/cpython-build-host.sh

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,28 @@ END
107107
fi
108108
fi
109109

110-
# OPT="$OPT"
111-
# CFLAGS="-DHAVE_FFI_PREP_CIF_VAR=1 -DHAVE_FFI_PREP_CLOSURE_LOC=1 -DHAVE_FFI_CLOSURE_ALLOC=1"
112-
if \
113-
CC=clang CXX=clang++ CFLAGS="-fPIC" CPPFLAGS="-fPIC" \
114-
${ROOT}/src/cpython${PYBUILD}/configure \
110+
if CC=clang CXX=clang++ CFLAGS="-fPIC" CPPFLAGS="-fPIC" \
111+
${ROOT}/src/cpython${PYBUILD}/configure \
115112
--prefix=$HOST_PREFIX $PYOPTS
116113
then
117-
make -j$(nproc) install
118-
rm -rf $(find $ROOT/devices/ -type d|grep __pycache__$)
119114

120-
rm $HOST_PREFIX/bin/*3 $HOST_PREFIX/bin/python3-config
121-
122-
patchelf --remove-needed libintl.so.8 $HOST_PREFIX/bin/python${PYBUILD}
123-
sed -i 's|-lintl ||g' ${SDKROOT}/devices/x86_64/usr/bin/python${PYBUILD}-config
124-
125-
cp -Rfv $ROOT/support/__EMSCRIPTEN__.patches/${PYBUILD}/. $HOST_PREFIX/lib/python${PYBUILD}/
115+
if make -j$(nproc) install
116+
then
117+
rm -rf $(find $ROOT/devices/ -type d|grep __pycache__$)
118+
rm $HOST_PREFIX/bin/python3-config \
119+
$HOST_PREFIX/bin/idle3 \
120+
$HOST_PREFIX/bin/pydoc3 \
121+
$HOST_PREFIX/bin/python3
122+
123+
# make ubuntu binaries able to run elsewhere
124+
patchelf --remove-needed libintl.so.8 $HOST_PREFIX/bin/python${PYBUILD}
125+
# and able to compile elsewhere
126+
sed -i 's|-lintl ||g' ${SDKROOT}/devices/x86_64/usr/bin/python${PYBUILD}-config
127+
cp -Rfv $ROOT/support/__EMSCRIPTEN__.patches/${PYBUILD}/. $HOST_PREFIX/lib/python${PYBUILD}/
128+
else
129+
echo "failed to build $PYTHON_FOR_BUILD"
130+
exit 123
131+
fi
126132
else
127133
echo "
128134
==========================================================================
@@ -131,7 +137,7 @@ END
131137
reminder: you need clang libffi-dev and usual cpython requirements.
132138
==========================================================================
133139
" 1>&2
134-
exit 1
140+
exit 133
135141
fi
136142

137143
popd

scripts/cpython-fetch.sh

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,34 @@ 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
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+
69+
wget -q -c https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz
70+
tar xf Python-3.12.0.tar.xz
71+
ln -s Python-3.12.0 cpython${PYBUILD}
72+
export REBUILD=true
6873
fi
6974

75+
7076
if echo $PYBUILD | grep -q 11$
7177
then
7278
wget -q -c https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tar.xz
@@ -89,7 +95,7 @@ fi
8995

9096
# the sys._emscripten_info is actually not compatible with shared build
9197
# because it uses javascript inlines
92-
# just move it to main
98+
# just move that part to main
9399

94100
if $NOPATCH
95101
then

scripts/emsdk-fetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ END
129129
ALL="$ALL libc libdlmalloc libcompiler_rt libc++-noexcept libc++abi-noexcept"
130130
ALL="$ALL libfetch zlib bzip2 libpng libjpeg freetype harfbuzz"
131131
ALL="$ALL sdl2 sdl2_mixer sdl2_gfx sdl2_ttf"
132-
ALL="$ALL sqlite3"
132+
ALL="$ALL sqlite3 vorbis ogg"
133133

134134
echo "
135135
* building third parties libraries for emsdk ( can take time ... )

sources.wasm/openssl.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
cd ${ROOT}/src
77
export OPENSSL="openssl-1.1.1s"
8-
export URL_OPENSSL=${URL_OPENSSL:-"URL https://ftp.openssl.org/source/$OPENSSL.tar.gz"}
9-
export HASH_OPENSSL="URL_HASH SHA256=c5ac01e760ee6ff0dab61d6b2bbd30146724d063eb322180c6f18a6f74e4b6aa"
8+
export URL_OPENSSL=https://ftp.openssl.org/source/$OPENSSL.tar.gz
109

1110

1211

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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();
71+
}
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], [" "])
106+
107+
dnl Include file system support
108+
AS_VAR_APPEND([LDFLAGS_NODIST], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""The asyncio package, tracking PEP 3156."""
2+
3+
# flake8: noqa
4+
5+
import sys
6+
7+
# This relies on each of the submodules having an __all__ variable.
8+
from .base_events import *
9+
from .coroutines import *
10+
from .events import *
11+
from .exceptions import *
12+
from .futures import *
13+
from .locks import *
14+
from .protocols import *
15+
from .runners import *
16+
from .queues import *
17+
from .streams import *
18+
from .subprocess import *
19+
from .tasks import *
20+
from .taskgroups import *
21+
from .timeouts import *
22+
from .threads import *
23+
from .transports import *
24+
25+
__all__ = (base_events.__all__ +
26+
coroutines.__all__ +
27+
events.__all__ +
28+
exceptions.__all__ +
29+
futures.__all__ +
30+
locks.__all__ +
31+
protocols.__all__ +
32+
runners.__all__ +
33+
queues.__all__ +
34+
streams.__all__ +
35+
subprocess.__all__ +
36+
tasks.__all__ +
37+
threads.__all__ +
38+
timeouts.__all__ +
39+
transports.__all__)
40+
41+
if sys.platform == 'win32': # pragma: no cover
42+
from .windows_events import *
43+
__all__ += windows_events.__all__
44+
elif sys.platform in ['emscripten','wasi']:
45+
from .wasm_events import *
46+
__all__ += wasm_events.__all__
47+
else:
48+
from .unix_events import * # pragma: no cover
49+
__all__ += unix_events.__all__

0 commit comments

Comments
 (0)