python: detect Python from custom Xcode installations (#27023)

This commit is contained in:
Ben Boeckel 2021-11-01 12:55:15 +00:00 committed by GitHub
parent 9094d6bb68
commit 80ba7040f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -797,6 +797,14 @@ def libs(self):
# install libraries into a Frameworks directory
frameworkprefix = self.config_vars['PYTHONFRAMEWORKPREFIX']
# Get the active Xcode environment's Framework location.
macos_developerdir = os.environ.get('DEVELOPER_DIR')
if macos_developerdir and os.path.exists(macos_developerdir):
macos_developerdir = os.path.join(
macos_developerdir, 'Library', 'Frameworks')
else:
macos_developerdir = ''
if '+shared' in self.spec:
ldlibrary = self.config_vars['LDLIBRARY']
@ -806,6 +814,9 @@ def libs(self):
return LibraryList(os.path.join(libpl, ldlibrary))
elif os.path.exists(os.path.join(frameworkprefix, ldlibrary)):
return LibraryList(os.path.join(frameworkprefix, ldlibrary))
elif macos_developerdir and \
os.path.exists(os.path.join(macos_developerdir, ldlibrary)):
return LibraryList(os.path.join(macos_developerdir, ldlibrary))
else:
msg = 'Unable to locate {0} libraries in {1}'
raise RuntimeError(msg.format(ldlibrary, libdir))