Skip to content

Commit 0802206

Browse files
authored
Update free-threading CI (#9625)
2 parents e7556b1 + 3f74d08 commit 0802206

3 files changed

Lines changed: 29 additions & 12 deletions

File tree

.ci/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ python3 -m pip install --only-binary=:all: pyarrow || true
3939
# PyQt6 doesn't support PyPy3
4040
if [[ $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
4444
fi
4545

4646
# webp

.github/workflows/test.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ jobs:
4242
"3.15",
4343
"3.14t",
4444
"3.14",
45-
"3.13t",
4645
"3.13",
4746
"3.12",
4847
"3.11",
@@ -51,10 +50,6 @@ jobs:
5150
include:
5251
- { python-version: "3.12", PYTHONOPTIMIZE: 1, REVERSE: "--reverse" }
5352
- { python-version: "3.11", PYTHONOPTIMIZE: 2 }
54-
# Free-threaded
55-
- { python-version: "3.15t", disable-gil: true }
56-
- { python-version: "3.14t", disable-gil: true }
57-
- { python-version: "3.13t", disable-gil: true }
5853
# Intel
5954
- { os: "macos-26-intel", python-version: "3.10" }
6055
exclude:
@@ -78,11 +73,6 @@ jobs:
7873
".ci/*.sh"
7974
"pyproject.toml"
8075
81-
- name: Set PYTHON_GIL
82-
if: "${{ matrix.disable-gil }}"
83-
run: |
84-
echo "PYTHON_GIL=0" >> $GITHUB_ENV
85-
8676
- name: Build system information
8777
run: python3 .github/workflows/system-info.py
8878

Tests/conftest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
from __future__ import annotations
22

33
import io
4+
import sys
5+
import sysconfig
46

57
import 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

816
def pytest_report_header(config: pytest.Config) -> str:
917
try:
@@ -16,6 +24,25 @@ def pytest_report_header(config: pytest.Config) -> str:
1624
return f"pytest_report_header failed: {e}"
1725

1826

27+
def pytest_terminal_summary(terminalreporter: pytest.TerminalReporter) -> None:
28+
if (
29+
FREE_THREADED_BUILD
30+
and not gil_enabled_at_start
31+
and sys._is_gil_enabled() # type: ignore[attr-defined]
32+
):
33+
tr = terminalreporter
34+
tr.ensure_newline()
35+
tr.section("GIL re-enabled", red=True, bold=True)
36+
tr.line("The GIL was re-enabled at runtime during the tests.")
37+
tr.line("This can happen with no test failures if the RuntimeWarning")
38+
tr.line("raised by Python when this happens is filtered by a test.")
39+
tr.line("")
40+
tr.line("Please ensure all new C modules declare support for running")
41+
tr.line("without the GIL. Any new tests that intentionally imports")
42+
tr.line("code that re-enables the GIL should do so in a subprocess.")
43+
pytest.exit("GIL re-enabled during tests", returncode=1)
44+
45+
1946
def pytest_configure(config: pytest.Config) -> None:
2047
config.addinivalue_line(
2148
"markers",

0 commit comments

Comments
 (0)