Pin CMake Python lookup to PYTHON_PREFIX on macOS#6456
Merged
Conversation
find_package(Python) ignores the legacy PYTHON_* hint variables, so with
CMake's framework-first search an x86_64 Python.framework linked into
/usr/local/Frameworks (Rosetta Homebrew, set up for cross-platform x64
builds) shadows the arm64 brew python: ld discards the wrong-arch
libpython and MRTest then aborts at launch with
"symbol not found in flat namespace '_PyExc_RuntimeError'".
Pass Python_ROOT_DIR and Python_FIND_FRAMEWORK=LAST so the interpreter
selected by python${PYTHON_VERSION}-config always wins.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Grantim
approved these changes
Jul 20, 2026
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.
Since 2026-07-18 every
macos-build-test (arm64, Debug)job on the MACBOOK-PRO-16-2021-TBI-2 runner fails: MRTest aborts at launch with(e.g. the nightly run 29713915367 and several Dependabot PRs, while identical jobs pass on the other mac runner).
Root cause: an x86_64 (Rosetta) Homebrew was set up on that machine for producing cross-platform x64 builds, which linked an Intel
Python.frameworkinto/usr/local/Frameworks.build_source.shonly passes the legacyPYTHON_LIBRARY/PYTHON_INCLUDE_DIR/PYTHON_EXECUTABLEhints, which modernfind_package(Python)ignores, and CMake's framework-first search order prefers/usr/local/Frameworksover the arm64 brew:MRPython is then linked with unresolved flat-namespace Python symbols and dyld aborts as soon as MRTest starts.
This PR pins the lookup: pass
Python_ROOT_DIR(derived frompython${PYTHON_VERSION}-config --prefix, i.e. the interpreter already selected by PATH) andPython_FIND_FRAMEWORK=LAST, so a foreign-arch framework in/usr/local/Frameworkscan never shadow the intended Python — on CI runners or on developer macs that have both brews installed.The Intel pythons still need to be unlinked on TBI-2 itself (
arch -x86_64 /usr/local/bin/brew unlink python@3.10 python@3.14), but with this change the build no longer depends on that machine state.🤖 Generated with Claude Code