Use FindPython3 consistently for source builds - #2830
Open
cdeil wants to merge 1 commit into
Open
Conversation
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.
Summary
Modernize source-build Python discovery so CMake uses one explicitly selected interpreter and its matching development and NumPy artifacts throughout the build.
FindPythonInterp/FindPythonLibslookup withFindPython3Python3_EXECUTABLEFindPython3derive matching artifactsThis addresses the Python-discovery and virtual-environment portions of #2376.
Problem
The old build can select different Python installations for the interpreter and development artifacts. On a machine with a uv-managed Python 3.13.11 environment and Homebrew Python 3.13.15, passing only
PYTHON_EXECUTABLEselected:The kmeans configure step also invoked the literal
python3fromPATH, independently of the selected interpreter. That can use another Python ABI or fail because that unrelated interpreter does not have the build dependencies.Fix
CMake 3.14 provides the
FindPython3NumPy component, so this raises the minimum to 3.14 and performs one component-aware lookup:All native includes and all Python build/test subprocesses then use results from that lookup. The build scripts pass only
Python3_EXECUTABLE; this avoids independently supplied header and library paths drifting to another installation.Red/green validation
Red: current
mainpython3executable first onPATHthat prints an error and exits 86.PATHexecutable from the kmeans step and failed:A second clean configure that supplied only the virtual-environment
PYTHON_EXECUTABLEcompleted but paired its Python 3.13.11 interpreter with Homebrew Python 3.13.15 headers and library.Green: this branch
Repeated the poisoned-
PATHconfigure while passing onlyPython3_EXECUTABLE:python3was never invoked in either casecmake --build <dir> --target dist -j4succeeded for both interpreterscp313andcp310macOS arm64 wheelscoremltoolsplus_MLModelProxysuccessfullyThe existing
build_wheel_macos_py310CI job runsscripts/build.sh --python=3.10 --dist, so it exercises the updated discovery and complete wheel-build path.