Skip to content

Commit 1ee327c

Browse files
committed
MAINT: re-add environment variable, add import test
1 parent 0858ae0 commit 1ee327c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.github/workflows/linux.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,6 @@ jobs:
311311
run: |
312312
pip install git+https://github.com/cython/cython
313313
- uses: ./.github/meson_actions
314+
env:
315+
# needed until f2py grows a config flag for GIL-disabled support
316+
PYTHON_GIL: 0

tools/wheels/cibw_test_command.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ if [[ $FREE_THREADED_BUILD == "True" ]]; then
3434
# with a released version of cython
3535
python -m pip uninstall -y cython
3636
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython
37+
38+
# Manually check that importing NumPy does not re-enable the GIL.
39+
# Afterwards, force the GIL to always be disabled so it does not get
40+
# re-enabled during the tests.
41+
#
42+
# TODO: delete when f2py grows the ability to define extensions that declare
43+
# they can run without the gil or when we can work around the fact the f2py
44+
# tests import modules that don't declare gil-disabled support.
45+
if [[ $(python -c "import numpy" 2>&1) == "*The global interpreter lock (GIL) has been enabled*" ]]; then
46+
echo "Error: Importing NumPy re-enables the GIL in the free-threaded build"
47+
exit 1
48+
fi
49+
50+
export PYTHON_GIL=0
3751
fi
3852

3953
# Run full tests with -n=auto. This makes pytest-xdist distribute tests across

0 commit comments

Comments
 (0)