Skip to content

macOS framework installs can break if DESTDIR specified during builds #149351

@ned-deily

Description

@ned-deily

Bug report

Bug description:

The Makefile build target for the shared Python library in a macOS framework build can include an incorrect library install name if the DESTDIR Makefile variable is set. The symptom is that launching the installed python3.x binary will result in a crash with the system unable to find the Python shared library; the path of the library will mistakenly include the DESTDIR path prefix.

The DESTDIR variable is often used in Makefile-based build pipelines to allow build artifacts to be installed temporarily in a directory tree other than the intended system installation location which could otherwise affect the system environment on the build platform. For a long time now, the value of DESTDIR, if specified, has been included in the install name path of the framework library. That hasn't caused a problem as long as the build is done in multiple make steps, for example:

./configure --enable-framework ...
make ... 
make install DESTDIR=release_directory

But if the first make were skipped such that the make install step causes the Python library to be linked, the DESTDIR path prefix will be include in the install name and the installed framework will not work. This could also happen if the make install step causes the library to be relinked due to a Makefile dependency issue, which is how this problem was discovered.

The solution is simple: don't include DESTDIR in the -install_name argument. Note that the very similar iOS framework build rule does not have this problem.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

OS-macbuildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions