Skip to content

Pin CMake Python lookup to PYTHON_PREFIX on macOS#6456

Merged
Fedr merged 1 commit into
masterfrom
ci/macos-pin-python-root-dir
Jul 20, 2026
Merged

Pin CMake Python lookup to PYTHON_PREFIX on macOS#6456
Fedr merged 1 commit into
masterfrom
ci/macos-pin-python-root-dir

Conversation

@Fedr

@Fedr Fedr commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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

dyld[26064]: symbol not found in flat namespace '_PyExc_RuntimeError'

(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.framework into /usr/local/Frameworks. build_source.sh only passes the legacy PYTHON_LIBRARY/PYTHON_INCLUDE_DIR/PYTHON_EXECUTABLE hints, which modern find_package(Python) ignores, and CMake's framework-first search order prefers /usr/local/Frameworks over the arm64 brew:

-- Found Python: /usr/local/Frameworks/Python.framework/Versions/3.10/bin/python3.10
ld: warning: ignoring file '/usr/local/opt/python@3.10/.../libpython3.10.dylib': found architecture 'x86_64', required architecture 'arm64'

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 from python${PYTHON_VERSION}-config --prefix, i.e. the interpreter already selected by PATH) and Python_FIND_FRAMEWORK=LAST, so a foreign-arch framework in /usr/local/Frameworks can 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

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>
@Fedr
Fedr merged commit 4047ab1 into master Jul 20, 2026
58 checks passed
@Fedr
Fedr deleted the ci/macos-pin-python-root-dir branch July 20, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants