Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Python 3.11 #303

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions recipes/recipes_emscripten/python/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

cp $RECIPE_DIR/patches/configure .

PYTHON=${BUILD_PREFIX}/bin/python3.10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would revert the hard-coded changes and only change it in the python recipe but not all the other recipes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, is it because this should be tackled in #308 instead?

PYTHON=${BUILD_PREFIX}/bin/python3.11

export DBGFLAGS=-g0
export OPTFLAGS=-O2
Expand All @@ -20,7 +20,7 @@ echo "EMSCRIPTEN_VERSION" $EMSCRIPTEN_VERSION
echo "PLATFORM_TRIPLET" $PLATFORM_TRIPLET


LIB=libpython3.10.a
LIB=libpython3.11.a



Expand Down Expand Up @@ -54,8 +54,8 @@ if [[ $target_platform == "emscripten-32" ]]; then

sed -i -e 's/libinstall:.*/libinstall:/' Makefile;

# emmake make PYTHON_FOR_BUILD=${BUILD_PREFIX}/bin/python3.10 CROSS_COMPILE=yes inclinstall libinstall ${LIB}
emmake make PYTHON_FOR_BUILD=${BUILD_PREFIX}/bin/python3.10 CROSS_COMPILE=yes inclinstall libinstall bininstall ${LIB}
# emmake make PYTHON_FOR_BUILD=${BUILD_PREFIX}/bin/python3.11 CROSS_COMPILE=yes inclinstall libinstall ${LIB}
emmake make PYTHON_FOR_BUILD=${BUILD_PREFIX}/bin/python3.11 CROSS_COMPILE=yes inclinstall libinstall bininstall ${LIB}
cp ${LIB} ${PREFIX}/lib/

emmake make CROSS_COMPILE=yes -j8
Expand All @@ -64,21 +64,21 @@ if [[ $target_platform == "emscripten-32" ]]; then
# "some/long/path/containing_the_build_dir/emcc" with "emcc"
# "some/long/path/containing_the_build_dir/emar" with "emar"
# "some/long/path/containing_the_build_dir/em++" with "em++"
FNAME_IN="build/lib.emscripten-3.10/$SYSCONFIG_NAME.py"
FNAME_OUT="build/lib.emscripten-3.10/$SYSCONFIG_NAME.py"
FNAME_IN="build/lib.emscripten-3.11/$SYSCONFIG_NAME.py"
FNAME_OUT="build/lib.emscripten-3.11/$SYSCONFIG_NAME.py"
$PYTHON $RECIPE_DIR/patch_sysconfigdata.py \
--fname-in $FNAME_IN \
--fname-out $FNAME_OUT \

cp build/lib.emscripten-3.10/$SYSCONFIG_NAME.py ${PREFIX}/lib/python3.10/
cp build/lib.emscripten-3.11/$SYSCONFIG_NAME.py ${PREFIX}/lib/python3.11/

# CHANGE PLATTFORM TRIPLET IN SYSCONFIG
sed -i "s/-lffi -lz/ /g" ${PREFIX}/lib/python3.10/$SYSCONFIG_NAME.py
# sed -i "s/'SHLIB_SUFFIX': '.so',/'SHLIB_SUFFIX': '.cpython-310-wasm32-emscripten.so',/g" ${PREFIX}/lib/python3.10/_sysconfigdata__emscripten_.py
sed -i "s/-lffi -lz/ /g" ${PREFIX}/lib/python3.11/$SYSCONFIG_NAME.py
# sed -i "s/'SHLIB_SUFFIX': '.so',/'SHLIB_SUFFIX': '.cpython-310-wasm32-emscripten.so',/g" ${PREFIX}/lib/python3.11/_sysconfigdata__emscripten_.py

# install/copy sysconfig to a place where cross-python expects the sysconfig
mkdir -p ${PREFIX}/etc/conda
cp ${PREFIX}/lib/python3.10/$SYSCONFIG_NAME.py ${PREFIX}/etc/conda/
cp ${PREFIX}/lib/python3.11/$SYSCONFIG_NAME.py ${PREFIX}/etc/conda/

# cleanup
pushd ${PREFIX}
Expand All @@ -91,17 +91,17 @@ if [[ $target_platform == "emscripten-32" ]]; then
popd

# remove the removal modules
pushd ${PREFIX}/lib/python3.10/
pushd ${PREFIX}/lib/python3.11/
rm -rf `cat ${RECIPE_DIR}/config/remove_modules.txt`
popd

# unwanted test dirs
rm -rf ${PREFIX}/lib/python3.10/ctypes/test
rm -rf ${PREFIX}/lib/python3.10/distutils/test
rm -rf ${PREFIX}/lib/python3.10/sqlite3/test
rm -rf ${PREFIX}/lib/python3.10/unittest/tests
rm -rf ${PREFIX}/lib/python3.11/ctypes/test
rm -rf ${PREFIX}/lib/python3.11/distutils/test
rm -rf ${PREFIX}/lib/python3.11/sqlite3/test
rm -rf ${PREFIX}/lib/python3.11/unittest/tests

# remove broken links but keep python3.10 binary
# remove broken links but keep python3.11 binary
# and the non-broken link to it
rm ${PREFIX}/bin/2to3
rm ${PREFIX}/bin/idle3
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 8dc93243eb0cdf27a81e9baf156df621cc8e2eb9 Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Sun, 17 Jul 2022 14:40:39 +0100
Subject: [PATCH 1/9] Public pymain_run_python

---
Modules/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Modules/main.c b/Modules/main.c
index 6904e3f76e..07bea58080 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -537,7 +537,7 @@ pymain_repl(PyConfig *config, int *exitcode)
}


-static void
+void
pymain_run_python(int *exitcode)
{
PyObject *main_importer_path = NULL;
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 90812b6dc97860ef164a2810ebf5f3121dfc919e Mon Sep 17 00:00:00 2001
From: Hood Chatham <[email protected]>
Date: Wed, 16 Nov 2022 14:02:53 -0800
Subject: [PATCH 2/9] Patch importlib to allow modifications to
ModuleNotFoundError

---
Lib/importlib/_bootstrap.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
index afb95f4e1d..32fe7a68bf 100644
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1119,6 +1119,9 @@ def _sanity_check(name, package, level):
_ERR_MSG_PREFIX = 'No module named '
_ERR_MSG = _ERR_MSG_PREFIX + '{!r}'

+def _get_module_not_found_error(name):
+ return ModuleNotFoundError(_ERR_MSG.format(name), name=name)
+
def _find_and_load_unlocked(name, import_):
path = None
parent = name.rpartition('.')[0]
@@ -1139,7 +1142,7 @@ def _find_and_load_unlocked(name, import_):
child = name.rpartition('.')[2]
spec = _find_spec(name, path)
if spec is None:
- raise ModuleNotFoundError(_ERR_MSG.format(name), name=name)
+ raise _get_module_not_found_error(name)
else:
if parent_spec:
# Temporarily add child we are currently importing to parent's
--
2.25.1

Loading