Fix free-threaded cross-compile builds by stating the Python ABI - #352
Merged
Conversation
When cross-compiling, pybind11 3.0 (via CMP0190) asks FindPython for Development.Module without the Interpreter component. CMake 4.4 deduces the free-threaded ABI from the interpreter, so with none available it defaults to GIL-enabled, rejects the python3.14t headers, and fails with Could NOT find Python (missing: Development.Module) Older CMake accepted the headers but derived a SOABI missing the "t" flag. Both are fixed by setting Python_FIND_ABI when the headers we were pointed at are free-threaded. This is what breaks the conda-forge cp314t builds for linux-aarch64, linux-ppc64le and osx-arm64, which cross-compile; cibuildwheel is unaffected because it never sets CMAKE_SYSTEM_NAME. Assisted-by: Claude Opus 5 <noreply@anthropic.com>
numpy's stubs now use PEP 695 "type" statements, and mypy refuses to parse those
while python_version targets 3.9, so the format job fails before it checks any of
our code:
numpy/__init__.pyi:737: error: Type statement is only supported in Python 3.12
and greater [syntax]
Found 1 error in 1 file (errors prevented further checking)
Skip numpy rather than raise python_version, so we keep type checking against the
oldest interpreter we ship wheels for. follow_imports alone does not cover .pyi
files, hence follow_imports_for_stubs; both are needed.
Bumping mypy does not help on its own -- v2.3.0 reports the same error, and it
additionally refuses python_version 3.9 outright ("must be 3.10 or higher"), so
taking that route would mean giving up 3.9 checking as well.
Assisted-by: Claude Opus 5 <noreply@anthropic.com>
cpp-peglib declares operator"" _ with the whitespace C++23 deprecates. The clang now on macos-latest diagnoses that by default, and our -Werror makes it fatal, so every macOS job fails on one line buried in Eigen's warning output: cpp-peglib/peglib.h:451:42: error: identifier '_' preceded by whitespace in a literal operator declaration is deprecated [-Werror,-Wdeprecated-literal-operator] Bumping cpp-peglib does not get us out of it. The fix landed upstream in v1.14.0, released four weeks ago, and every release carrying it has also dropped the parser.log member that formula_ast.cc assigns to -- v1.15.1 fails with "no member named 'log' in 'peg::parser'". No version both fixes the warning and builds against our source, so migrating to set_logger is a deliberate change for after the release rather than something to rush in now. The check probes the positive form of the warning: compilers accept unknown -Wno-* options silently, so probing -Wno-deprecated-literal-operator would succeed everywhere and tell us nothing, including on gcc, which has no such warning. Assisted-by: Claude Opus 5 <noreply@anthropic.com>
CVMFS benchmarksTop 25 slowest-loading corrections, sorted by mean time:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses CMake cross-compilation failures for free-threaded CPython 3.14 (cp314t) by explicitly setting the Python ABI so FindPython can resolve Development.Module correctly when no interpreter is available (as happens under cross-compiling). It also adjusts build warning handling and type-checking configuration.
Changes:
- Set
Python_FIND_ABIbased onPy_GIL_DISABLEDdetected frompyconfig.hto fix CMake 4.4+ free-threaded cross-compilation discovery. - Conditionally suppress
-Wdeprecated-literal-operatorforcpp-peglibunder-Werrorbuilds (non-MSVC). - Update mypy configuration to follow imports for stubs and skip
numpystubs to avoid parsing issues while targeting Python 3.9.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
CMakeLists.txt |
Adds free-threaded ABI hinting for cross-compiling and gates a clang warning suppression for cpp-peglib. |
pyproject.toml |
Updates mypy behavior for stub imports and skips numpy stubs under the current python_version target. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This description is agent-generated text, written by Claude Opus 5 via Claude Code.
The conda-forge
cp314t(free-threaded 3.14) builds fail on exactly the threecross-compiled targets —
linux-aarch64,linux-ppc64le,osx-arm64— withSee conda-forge/correctionlib-feedstock#37. Native
cp314tbuilds pass, and so doall the cross-compiled GIL-enabled variants, so it takes cross-compiling and
free-threading together.
Cause
CMAKE_ARGSpasses-DCMAKE_SYSTEM_NAME=Linux, soCMAKE_CROSSCOMPILINGis true.and drops the
Interpretercomponent when cross-compiling.FindPythondeduces the free-threaded ABI from the interpreter. Withno interpreter it falls back to GIL-enabled and rejects the
python3.14theadersthat scikit-build-core points it at — the version still gets read out of
patchlevel.h, hence the "found suitable version 3.14.6" in the same message.Nothing is wrong on the conda-forge side, and cibuildwheel is unaffected because it
never sets
CMAKE_SYSTEM_NAME.Worth noting that CMake <= 4.3 did not error here — it silently computed a SOABI
without the
tflag (cpython-314-linux-aarch64), i.e. a mis-named extensionmodule. 4.4 turned that into a hard error.
Fix
State the ABI explicitly when the headers we were handed are free-threaded, before
pybind11 runs
find_package(Python).Testing
Reproduced locally with CMake 4.4.0 (conda-forge uses 4.4.1), a free-threaded
CPython 3.14.3, and a toolchain file setting only
CMAKE_SYSTEM_NAME/CMAKE_SYSTEM_PROCESSORto tripCMAKE_CROSSCOMPILING:Could NOT find Python (missing: Development.Module), same as CIfound components: Development.Module Development.Embed,Python_SOABI: cpython-314t-darwin, and_core.cpython-314t-darwin.sobuildsand links
pyconfig.hguard doesn't fire)Follow-up
The cpp-peglib suppression here is a workaround, not a fix; #354 tracks bumping the
submodule and migrating off the removed
parser.logAPI.