Skip to content

Commit e4ff46f

Browse files
committed
CI: use Pythran master to build free-threaded wheels [wheel build]
Marking extension modules as thread-safe will only be available in Pythran 0.17.1, and that is not yet released. This is the last change needed to ensure the GIL isn't re-enabled on import. Also add a CI check that no new extension modules without declared free-threading support sneak back in.
1 parent 97bd543 commit e4ff46f

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

tools/wheels/cibw_before_build_linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_conf
2424
if [[ $FREE_THREADED_BUILD == "True" ]]; then
2525
python -m pip install -U --pre pip
2626
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy cython
27-
# python -m pip install git+https://github.com/serge-sans-paille/pythran
28-
python -m pip install ninja meson-python pybind11 pythran
27+
python -m pip install git+https://github.com/serge-sans-paille/pythran
28+
python -m pip install ninja meson-python pybind11
2929
fi
3030

3131
# Install Openblas

tools/wheels/cibw_before_build_macos.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_conf
6666
if [[ $FREE_THREADED_BUILD == "True" ]]; then
6767
python -m pip install -U --pre pip
6868
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy cython
69-
# python -m pip install git+https://github.com/serge-sans-paille/pythran
70-
python -m pip install ninja meson-python pybind11 pythran
69+
python -m pip install git+https://github.com/serge-sans-paille/pythran
70+
python -m pip install ninja meson-python pybind11
7171
fi
7272

7373
# Install Openblas

tools/wheels/cibw_before_build_win.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_conf
1717
if [[ $FREE_THREADED_BUILD == "True" ]]; then
1818
python -m pip install -U --pre pip
1919
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy cython
20-
# TODO: Remove meson installation from source once a new release
21-
# that includes https://github.com/mesonbuild/meson/pull/13851 is available
22-
python -m pip install git+https://github.com/mesonbuild/meson
23-
python -m pip install ninja meson-python pybind11 pythran
20+
python -m pip install git+https://github.com/serge-sans-paille/pythran
21+
python -m pip install ninja meson-python pybind11
2422
fi
2523

2624
# delvewheel is the equivalent of delocate/auditwheel for windows.

tools/wheels/cibw_test_command.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ set -xe
22

33
FREE_THREADED_BUILD="$(python -c"import sysconfig; print(bool(sysconfig.get_config_var('Py_GIL_DISABLED')))")"
44
if [[ $FREE_THREADED_BUILD == "True" ]]; then
5-
# TODO: delete when importing numpy no longer enables the GIL
6-
# setting to zero ensures the GIL is disabled while running the
7-
# tests under free-threaded python
8-
export PYTHON_GIL=0
5+
# Manually check that importing SciPy does not re-enable the GIL.
6+
# In principle the tests should catch this but it seems harmless to leave it
7+
# here as a final sanity check before uploading broken wheels
8+
if [[ $(python -c "import scipy.stats" 2>&1) == *"The global interpreter lock (GIL) has been enabled"* ]]; then
9+
echo "Error: Importing SciPy re-enables the GIL in the free-threaded build"
10+
exit 1
11+
fi
12+
913
fi
1014

1115
python -c "import sys; import scipy; sys.exit(not scipy.test())"

0 commit comments

Comments
 (0)