File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,8 +39,8 @@ python3 -m pip install --only-binary=:all: pyarrow || true
3939# PyQt6 doesn't support PyPy3
4040if [[ $GHA_PYTHON_VERSION == 3.* ]]; then
4141 sudo apt-get -qq install libegl1 libxcb-cursor0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxkbcommon-x11-0
42- # TODO Update condition when pyqt6 supports free-threading
43- if ! [[ " $PYTHON_GIL " == " 0 " ]] ; then python3 -m pip install pyqt6 ; fi
42+ # pyqt6 doesn't yet support free-threading; only install if a wheel is available
43+ python3 -m pip install --only-binary=:all: pyqt6 || true
4444fi
4545
4646# webp
Original file line number Diff line number Diff line change 7373 ".ci/*.sh"
7474 "pyproject.toml"
7575
76- - name : Set PYTHON_GIL
77- if : endsWith(matrix.python-version, 't')
78- run : |
79- echo "PYTHON_GIL=0" >> $GITHUB_ENV
80-
8176 - name : Build system information
8277 run : python3 .github/workflows/system-info.py
8378
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33import io
4+ import sys
5+ import sysconfig
46
57import pytest
68
9+ FREE_THREADED_BUILD = bool (sysconfig .get_config_var ("Py_GIL_DISABLED" ))
10+
11+ gil_enabled_at_start = True
12+ if FREE_THREADED_BUILD :
13+ gil_enabled_at_start = sys ._is_gil_enabled () # type: ignore[attr-defined]
14+
715
816def pytest_report_header (config : pytest .Config ) -> str :
917 try :
@@ -16,6 +24,27 @@ def pytest_report_header(config: pytest.Config) -> str:
1624 return f"pytest_report_header failed: { e } "
1725
1826
27+ def pytest_terminal_summary (
28+ terminalreporter : pytest .TerminalReporter , exitstatus : int , config : pytest .Config
29+ ) -> None :
30+ if (
31+ FREE_THREADED_BUILD
32+ and not gil_enabled_at_start
33+ and sys ._is_gil_enabled () # type: ignore[attr-defined]
34+ ):
35+ tr = terminalreporter
36+ tr .ensure_newline ()
37+ tr .section ("GIL re-enabled" , sep = "=" , red = True , bold = True )
38+ tr .line ("The GIL was re-enabled at runtime during the tests." )
39+ tr .line ("This can happen with no test failures if the RuntimeWarning" )
40+ tr .line ("raised by Python when this happens is filtered by a test." )
41+ tr .line ("" )
42+ tr .line ("Please ensure all new C modules declare support for running" )
43+ tr .line ("without the GIL. Any new tests that intentionally imports" )
44+ tr .line ("code that re-enables the GIL should do so in a subprocess." )
45+ pytest .exit ("GIL re-enabled during tests" , returncode = 1 )
46+
47+
1948def pytest_configure (config : pytest .Config ) -> None :
2049 config .addinivalue_line (
2150 "markers" ,
You can’t perform that action at this time.
0 commit comments