Skip to content

Commit 6799894

Browse files
committed
Update python to 3.14
1 parent 344b9c5 commit 6799894

4 files changed

Lines changed: 34 additions & 19 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ set(CMAKE_EXECUTABLE_SUFFIX ".wasm")
66

77
add_compile_options(-Werror -Wall -Wextra -Wimplicit-fallthrough)
88

9-
add_link_options(-Wl,--max-memory=67108864)
9+
add_link_options(-Wl,--max-memory=67108864 -z stack-size=16777216 -Wl,--stack-first -Wl,--initial-memory=41943040)
1010

1111
add_executable(python-host pyhost.c)
1212

1313
find_package(Python COMPONENTS Development)
1414

15-
target_link_libraries(python-host PUBLIC Python::Python wasi_vfs)
15+
target_link_libraries(python-host PUBLIC Python::Python wasi_vfs wasi-emulated-signal wasi-emulated-getpid wasi-emulated-process-clocks)

Dockerfile

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ENV WASMTIME_VERSION=42.0.1
1515
ENV WIZER_VERSION=10.0.0
1616
ENV WASI_VFS_VERSION=0.6.2
1717
ENV PYTHON_PATH=/opt/wasi-python
18-
ENV PYTHON_PYLIB=${PYTHON_PATH}/lib/python3.13
18+
ENV PYTHON_PYLIB=${PYTHON_PATH}/lib/python3.14
1919
ENV PYTHON_SITE=${PYTHON_PYLIB}/site-packages
2020

2121
RUN <<EOF
@@ -67,32 +67,45 @@ EOF
6767

6868
RUN <<EOF
6969
mkdir -p /build/cpython
70-
curl -L https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz | \
70+
curl -L https://www.python.org/ftp/python/3.14.3/Python-3.14.3.tgz | \
7171
tar -xz --strip-components 1 -C /build/cpython
7272
EOF
7373

74+
RUN <<'EOF'
75+
cd /build/cpython
76+
sed -i '/!_Py__has_attribute(preserve_none)/,/# endif/{
77+
s/# if !_Py__has_attribute(preserve_none) || !_Py__has_attribute(musttail)/# if !_Py__has_attribute(musttail)/
78+
}' Python/ceval_macros.h
79+
sed -i 's/# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))/# if _Py__has_attribute(preserve_none)\n# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))\n# else\n# define Py_PRESERVE_NONE_CC\n# endif/' Python/ceval_macros.h
80+
EOF
81+
7482
RUN <<EOF
7583
cd /build/cpython
76-
python3 Tools/wasm/wasi.py configure-build-python
77-
python3 Tools/wasm/wasi.py make-build-python
84+
python3 Tools/wasm/wasi configure-build-python
85+
python3 Tools/wasm/wasi make-build-python
7886
EOF
7987

8088
RUN <<EOF
8189
cd /build/cpython
82-
python3 Tools/wasm/wasi.py configure-host -- \
83-
CFLAGS='-Os' --prefix=${PYTHON_PATH} --disable-test-modules
84-
python3 Tools/wasm/wasi.py make-host
85-
make -C cross-build/wasm32-wasi install COMPILEALL_OPTS='-j0 -b'
90+
python3 Tools/wasm/wasi configure-host -- \
91+
CFLAGS='-Os -mtail-call' --prefix=${PYTHON_PATH} --disable-test-modules --with-tail-call-interp
92+
python3 Tools/wasm/wasi make-host
93+
make -C cross-build/wasm32-wasip1 install COMPILEALL_OPTS='-j0 -b'
8694
EOF
8795

8896
RUN <<EOF
89-
cd /build/cpython/cross-build/wasm32-wasi
97+
cd /build/cpython/cross-build/wasm32-wasip1
9098
${WASI_SDK_PATH}/bin/ar -M <<AR
91-
create ${PYTHON_PATH}/lib/libpython3.13.a
92-
addlib libpython3.13.a
99+
create ${PYTHON_PATH}/lib/libpython3.14.a
100+
addlib libpython3.14.a
93101
addlib Modules/expat/libexpat.a
94102
addlib Modules/_decimal/libmpdec/libmpdec.a
103+
addlib Modules/_hacl/libHacl_Hash_BLAKE2.a
104+
addlib Modules/_hacl/libHacl_Hash_MD5.a
105+
addlib Modules/_hacl/libHacl_Hash_SHA1.a
95106
addlib Modules/_hacl/libHacl_Hash_SHA2.a
107+
addlib Modules/_hacl/libHacl_Hash_SHA3.a
108+
addlib Modules/_hacl/libHacl_HMAC.a
96109
addlib ${WASI_SDK_LIBDIR}/libz.a
97110
save
98111
end
@@ -102,7 +115,7 @@ EOF
102115
RUN <<EOF
103116
cd ${PYTHON_PYLIB}
104117
find . -name __pycache__ -exec rm -rf {} \;
105-
rm -rf config-3.13-wasm32-wasi
118+
rm -rf config-3.14-wasm32-wasi
106119
rm -rf _*_support* _pyrepl bdb concurrent curses ensurepip doctest* idlelib
107120
rm -rf multiprocessing pdb pydoc* socketserver* sqlite3 ssl* subprocess*
108121
rm -rf tkinter turtle* unittest venv webbrowser* wsgiref xmlrpc
@@ -117,5 +130,5 @@ RUN <<EOF
117130
cd ${PYTHON_SITE}
118131
find . -name '*.dist-info' -exec rm -rf {} \;
119132
rm -rf bin
120-
/build/cpython/cross-build/build/python -m compileall -b .
133+
$(find /build/cpython/cross-build -maxdepth 2 -name python -not -path '*/wasm32-*' -type f) -m compileall -b .
121134
EOF

build-wasm.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ export CMAKE_EXTRA_ARGS="
1414
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
1515
-DWASI_SDK_PREFIX=${WASI_SDK_PATH}
1616
-DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk.cmake
17-
-DCMAKE_PREFIX_PATH=/opt/wasi-python"
17+
-DCMAKE_PREFIX_PATH=/opt/wasi-python
18+
-DPython_INCLUDE_DIR=/opt/wasi-python/include/python3.14
19+
-DPython_LIBRARY=/opt/wasi-python/lib/libpython3.14.a"
1820

1921
cmake -B ${TARGET_DIR} ${CMAKE_EXTRA_ARGS} .
2022
cmake --build ${TARGET_DIR} --verbose
2123

2224
rm -rf "${TARGET_DIR}"/python
2325

24-
cp -a ${PYTHON_PATH}/lib/python3.13 ${TARGET_DIR}/python
26+
cp -a ${PYTHON_PATH}/lib/python3.14 ${TARGET_DIR}/python
2527
cp /work/trino.py ${TARGET_DIR}/python/site-packages/
2628

2729
wasi-vfs pack ${TARGET_DIR}/python-host.wasm \
28-
--dir ${TARGET_DIR}/python::/opt/wasi-python/lib/python3.13 \
30+
--dir ${TARGET_DIR}/python::/opt/wasi-python/lib/python3.14 \
2931
--output ${TARGET_DIR}/python-host-packed.wasm
3032

3133
rm -rf "${TARGET_DIR}"/empty

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<groupId>io.trino</groupId>
1212
<artifactId>trino-wasm-python</artifactId>
13-
<version>3.13-6-SNAPSHOT</version>
13+
<version>3.14-1-SNAPSHOT</version>
1414
<packaging>jar</packaging>
1515

1616
<name>${project.artifactId}</name>

0 commit comments

Comments
 (0)