Skip to content

Commit

Permalink
Python: Work around missing rpath in Xcode python3-embed
Browse files Browse the repository at this point in the history
This enables generating Python bindings and linking against
`python3-embed` without resorting to later `install_name_tool` changes,
as the pkg-config module provided by Xcode doesn't say that
Python3.framework requires a rpath entry:

    $ otool -L /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Python3
    /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Python3:
                @rpath/Python3.framework/Versions/3.9/Python3 (compatibility version 3.9.0, current version 3.9.0)
                /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1933.0.0)
                /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
  • Loading branch information
amyspark authored and nirbheek committed Jan 30, 2025
1 parent d25fcbb commit c616f1e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mesonbuild/dependencies/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def __init__(self, name: str, environment: 'Environment',
if not self.link_libpython and mesonlib.version_compare(self.version, '< 3.8'):
self.link_args = []

# But not Apple, because it's a framework
if self.env.machines.host.is_darwin() and 'PYTHONFRAMEWORKPREFIX' in self.variables:
framework_prefix = self.variables['PYTHONFRAMEWORKPREFIX']
# Add rpath, will be de-duplicated if necessary
if framework_prefix.startswith('/Applications/Xcode.app/'):
self.link_args += ['-rpath,' + framework_prefix]

class PythonFrameworkDependency(ExtraFrameworkDependency, _PythonDependencyBase):

Expand Down

0 comments on commit c616f1e

Please sign in to comment.