Skip to content

Commit 3ca649b

Browse files
Transurgeonclaude
andcommitted
Tidy the free-threaded wheel build configuration
No functional change to the default builds. CIBW_ENABLE=cpython-freethreading was a no-op here. cibuildwheel 3.3.0 gates only cp313t behind that group (selector.py checks fnmatch(build_id, "cp313t-*") before consulting the enable set); cp314t is selectable by default, and this matrix builds no cp313t. The option is also deprecated in 3.4.1 and removed in 4.0, so leaving it set would break a later cibuildwheel bump for no benefit. The matrix excludes now say why each one is there. 3.11t and 3.12t are not build identifiers at all, since free threading starts at 3.13, so without the exclude cibuildwheel selects nothing and the job fails on an empty wheelhouse. 3.13t is a deliberate choice about NumPy instead: no cp313t wheels are published from 2.5 onwards, 2.4.6 being the last, which was confirmed by installing numpy on a free-threaded 3.13 and watching 2.5.3 build from source. CIBW_TEST_COMMAND uses bool(...) rather than == 1 on the Py_GIL_DISABLED config var. The var is always an int on 3.13+, on Windows too, so this is not a fix, just the idiom the free-threading porting guide uses. It also prints the flag so the log shows which ABI the job exercised. cmake.version moves to >=3.30.3. CMake 3.30 is the first whose FindPython3 understands the free-threaded "t" ABI, and scikit-build-core only sends the Python3_FIND_ABI hint when the configured specifier admits 3.30+, so at >=3.15 a 3.15-3.29 system CMake would silently skip it. 3.30.3 adds the Python3_DEFINITIONS that a Windows free-threaded build needs, since PC/pyconfig.h relies on Py_GIL_DISABLED being defined to auto-link python3XXt.lib. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent ae8799c commit 3ca649b

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

‎.github/workflows/build-and-publish.yml‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,18 @@ jobs:
3232
matrix:
3333
os: [ ubuntu-22.04, macos-14, windows-2022 ]
3434
python-version: [ "3.11", "3.12", "3.13", "3.14" ]
35-
# "" builds the default (GIL) interpreter, "t" the free-threaded one.
36-
# Only 3.14t: NumPy >= 2.5 ships no cp313t wheels on any platform, so a
37-
# 3.13t build would have to compile NumPy from source.
35+
# "" builds the default interpreter, "t" the free-threaded one.
3836
abi: [ "", "t" ]
3937
exclude:
40-
- python-version: "3.11"
41-
abi: "t"
42-
- python-version: "3.12"
43-
abi: "t"
44-
- python-version: "3.13"
45-
abi: "t"
38+
# Free threading does not exist before 3.13: cp311t and cp312t are
39+
# not build identifiers at all, so cibuildwheel would select nothing
40+
# and the job would fail on an empty wheelhouse.
41+
- { python-version: "3.11", abi: "t" }
42+
- { python-version: "3.12", abi: "t" }
43+
# NumPy ships no cp313t wheels from 2.5 onwards (2.4.6 is the last
44+
# release with one), so a 3.13t build would compile NumPy from
45+
# source: that timed out under QEMU and failed outright on macOS.
46+
- { python-version: "3.13", abi: "t" }
4647

4748
env:
4849
PYTHON_VERSION: ${{ matrix.python-version }}
@@ -71,10 +72,9 @@ jobs:
7172
- name: Build wheels
7273
uses: pypa/cibuildwheel@v3.3.0
7374
env:
75+
# No CIBW_ENABLE needed: cibuildwheel 3.x gates only cp313t behind
76+
# cpython-freethreading, and cp314t is selectable by default.
7477
CIBW_BUILD: "cp3${{ env.PYTHON_SUBVERSION }}${{ matrix.abi }}-*"
75-
# Opt in to cp3XXt build identifiers; harmless for the GIL builds since
76-
# CIBW_BUILD already selects a single ABI.
77-
CIBW_ENABLE: "cpython-freethreading"
7878
CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux*"
7979
CIBW_ARCHS_MACOS: "x86_64 universal2"
8080
CIBW_ARCHS_LINUX: "auto aarch64"
@@ -83,9 +83,9 @@ jobs:
8383
CIBW_ENVIRONMENT_WINDOWS: "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
8484
# Bundle openblas.dll into the wheel (auditwheel/delocate handle this on Linux/macOS)
8585
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel} --add-path C:/vcpkg/installed/x64-windows/bin"
86-
# On free-threaded builds also assert the import did not re-enable the GIL,
87-
# i.e. the extension really declares Py_MOD_GIL_NOT_USED.
88-
CIBW_TEST_COMMAND: python -c "import sys, sysconfig, sparsediffpy; ft = sysconfig.get_config_var('Py_GIL_DISABLED') == 1; assert not ft or not sys._is_gil_enabled(), 'GIL re-enabled on import'"
86+
# On free-threaded builds also assert the import did not re-enable the
87+
# GIL, i.e. the extension really declares Py_MOD_GIL_NOT_USED.
88+
CIBW_TEST_COMMAND: python -c "import sys, sysconfig, sparsediffpy; ft = bool(sysconfig.get_config_var('Py_GIL_DISABLED')); assert not ft or not sys._is_gil_enabled(), 'GIL re-enabled on import'; print('freethreaded_build=', ft)"
8989
- name: Check wheels
9090
shell: bash
9191
run: |

‎pyproject.toml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ file = "README.md"
1515
content-type = "text/markdown"
1616

1717
[tool.scikit-build]
18-
cmake.version = ">=3.15"
18+
# CMake 3.30 is the first whose FindPython3 understands the free-threaded ("t")
19+
# ABI, and scikit-build-core only sends the Python3_FIND_ABI hint when this
20+
# specifier admits 3.30+. 3.30.3 adds the Python3_DEFINITIONS a Windows
21+
# free-threaded build needs to link python3XXt.lib.
22+
cmake.version = ">=3.30.3"
1923
cmake.build-type = "Release"
2024
wheel.packages = ["sparsediffpy"]
2125
# Persistent build dir: avoids scikit-build-core's TemporaryDirectory, whose cleanup

0 commit comments

Comments
 (0)