Skip to content

gh-81218: Make macOS framework builds relocatable via @rpath - #144305

Open
dmnq-f wants to merge 3 commits into
python:mainfrom
dmnq-f:gh-81218-relocatable-framework-rpath
Open

dmnq-f wants to merge 3 commits into
python:mainfrom
dmnq-f:gh-81218-relocatable-framework-rpath

Conversation

@dmnq-f

@dmnq-f dmnq-f commented Jan 28, 2026 •

Copy link
Copy Markdown

With these changes, macOS framework builds (--enable-framework) produce relocatable frameworks. The installed framework can be moved to any location and will work without requiring install_name_tool rewriting by users.

This uses install-time transformation: build-time behavior is unchanged (absolute install names), and install_name_tool transforms the installed binaries to use appropriate @rpath.

iOS target already uses @rpath at build time because iOS builds are cross-compiled—there's no ./python.exe execution, no venvs, no shell script tests during development. macOS framework builds are different though and would break build-tree workflows because venv symlinks cause @executable_path to resolve to the wrong directory, SIP strips DYLD_FRAMEWORK_PATH from shell scripts, and so on.

The install-time approach avoids all these issues, introducing no regression for build-tree workflows, follows existing patterns (CMake projects, Qt, ...) and makes the installed framework fully relocatable by default.

Changes

  • Add -headerpad_max_install_names to LINKFORSHARED and pythonw build
  • Transform dylib install name to @rpath at install time
  • Add LC_RPATH entries to installed binaries (bin/python3, Python.app)
  • Compute rpath depths dynamically via os.path.relpath()

Related

@python-cla-bot

python-cla-bot Bot commented Jan 28, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@StanFromIreland

Copy link
Copy Markdown
Member

CC @sethmlarson, the fuzzers are failing, and it doesn't seem related.

macOS framework builds (--enable-framework) now produce relocatable
frameworks. The installed framework can be moved to any location and
will work without requiring install_name_tool rewriting by users.

This uses install-time transformation: build-time behavior is unchanged
(absolute install names), and install_name_tool transforms the installed
binaries to use @rpath.

Changes:
- Add -headerpad_max_install_names to LINKFORSHARED and pythonw build
- Transform dylib install name to @rpath at install time
- Add LC_RPATH entries to installed binaries (bin/python3, Python.app)
- Compute rpath depths dynamically via os.path.relpath()

Signed-off-by: Dominique Fuchs <[email protected]>
@dmnq-f
dmnq-f force-pushed the gh-81218-relocatable-framework-rpath branch from 31893c4 to 3ac12f5 Compare February 1, 2026 12:17
@dmnq-f

dmnq-f commented Feb 1, 2026 •

Copy link
Copy Markdown
Author

CC @sethmlarson, the fuzzers are failing, and it doesn't seem related.

Yeah, just rebased to current main, and they still do (indeed though, it looks totally unrelated to me and seems to happen to the other few CI runs where fuzzer runs are active and not manually skipped, too).

Update: Latest merge from current master doesn't show failing fuzzers anymore, it seems.

@ned-deily ned-deily self-assigned this Feb 11, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 5, 2026
@dmnq-f

dmnq-f commented May 5, 2026

Copy link
Copy Markdown
Author

This PR is stale because it has been open for 30 days with no activity.

Good point, bot 👏🏻.

@ned-deily I see you self-assigned this early on, but there has never been any comment on the actual PR content. Is this something to keep open or anything in it to align?

@ned-deily

Copy link
Copy Markdown
Member

Is this something to keep open or anything in it to align?

Thanks for the PR and for your patience. I am reviewing it now and may have some comments later.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 17, 2026
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relocatable framework for macOS Enable rpath remapping in makefile

3 participants