fix: cross-compilation updates#5829
Merged
henryiii merged 2 commits intopybind:masterfrom Jan 20, 2026
Merged
Conversation
This was referenced Sep 5, 2025
a00f560 to
60a0817
Compare
henryiii
approved these changes
Jan 20, 2026
Collaborator
|
@mhsmith is this ready to go in? |
Contributor
Author
|
Yes, I think so. |
henryiii
added a commit
to scikit-build/scikit-build-core
that referenced
this pull request
Jan 22, 2026
The main motivation for this PR is CMake policy [CMP0190](https://cmake.org/cmake/help/latest/policy/CMP0190.html), which will prohibit calling FindPython with both the `Interpreter` and `Development` components at the same time when cross-compiling. To encourage packages to be compatible with cross-compilation, I've removed `Interpreter` from all the documentation, examples and tests, except for the places which actually needed it. CMake is still able to find the Android Python libraries by itself without an interpreter, but it takes a very long time (20 seconds). Going by the [`--debug-find`](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-debug-find) option, this may be because it's searching a huge number of nonexistent paths, including every possible combination of Python version and `abiflags` *squared* (both for the directory name and the library name). So I've changed builder.py to tell CMake the Python library location on Android, as it already does on Windows. This performance problem doesn't affect the other Unix platforms, because they have the `python3.x-config` script available. See also: * pybind/pybind11#5829 --------- Co-authored-by: Henry Schreiner <[email protected]>
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.
Description
This PR updates the Android linking workaround in pybind11NewTools.cmake to be compatible with vcpkg, as discussed at #5733 (review). I've also submitted an upstream fix to CMake, so this workaround can eventually be removed.
However, most of the PR is about CMake policy CMP0190, which prohibits calling FindPython with both the
InterpreterandDevelopmentcomponents at the same time when cross-compiling:Enabled
PYBIND11_USE_CROSSCOMPILINGwhenever CMP0190 is in effect.Updated pybind11NewTools.cmake so it no longer requires the
Interpretercomponent, whether cross-compiling or not. This allows packages to use the same configuration for both cases.Improved pybind11GuessPythonExtSuffix.cmake:
SKBUILD_SOABIas another possible source of the Python module suffix.CACHE, just as they are when they're detected from the interpreter. Previously they were set to thePARENT_SCOPE, but that's the module scope of pybind11NewTools.cmake, which isn't accessible when calling functions from a different module. As a result, modules created usingpybind11_add_modulewere being built with no extension at all!To encourage packages to be compatible with cross-compilation, I've removedI've now reverted this for the reasons explained in scikit-build-core#1142 (comment).Interpreterfrom all the documentation, examples and tests, except for the places which actually needed it.The new policy can be tested by changing the
cmake_minimum_requiredupper limit in CMakeLists.txt from 4.0 to 4.1, and then using cibuildwheel to build thetestsproject. However, I haven't changed thecmake_minimum_requiredin this PR, because I'm not sure what other effects it might have.See also:
Suggested changelog entry:
📚 Documentation preview 📚: https://pybind11--5829.org.readthedocs.build/