mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Issue #14018: Fix OS X Tcl/Tk framework checking when using OS X SDKs.
Also add tests in the OS X installer build to ensure that the desired dynamic linking with an optional newer Tcl/Tk in /Library actually happens.
This commit is contained in:
parent
5d6aeb8d99
commit
2910a7ba6b
3 changed files with 50 additions and 13 deletions
|
|
@ -161,6 +161,13 @@ USAGE = textwrap.dedent("""\
|
||||||
--universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r)
|
--universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r)
|
||||||
""")% globals()
|
""")% globals()
|
||||||
|
|
||||||
|
# Dict of object file names with shared library names to check after building.
|
||||||
|
# This is to ensure that we ended up dynamically linking with the shared
|
||||||
|
# library paths and versions we expected. For example:
|
||||||
|
# EXPECTED_SHARED_LIBS['_tkinter.so'] = [
|
||||||
|
# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl',
|
||||||
|
# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk']
|
||||||
|
EXPECTED_SHARED_LIBS = {}
|
||||||
|
|
||||||
# Instructions for building libraries that are necessary for building a
|
# Instructions for building libraries that are necessary for building a
|
||||||
# batteries included python.
|
# batteries included python.
|
||||||
|
|
@ -460,27 +467,40 @@ def checkEnvironment():
|
||||||
# Because we only support dynamic load of only one major/minor version of
|
# Because we only support dynamic load of only one major/minor version of
|
||||||
# Tcl/Tk, ensure:
|
# Tcl/Tk, ensure:
|
||||||
# 1. there are no user-installed frameworks of Tcl/Tk with version
|
# 1. there are no user-installed frameworks of Tcl/Tk with version
|
||||||
# higher than the Apple-supplied system version
|
# higher than the Apple-supplied system version in
|
||||||
# 2. there is a user-installed framework in /Library/Frameworks with the
|
# SDKROOT/System/Library/Frameworks
|
||||||
# same version as the system version. This allows users to choose
|
# 2. there is a user-installed framework (usually ActiveTcl) in (or linked
|
||||||
# to install a newer patch level.
|
# in) SDKROOT/Library/Frameworks with the same version as the system
|
||||||
|
# version. This allows users to choose to install a newer patch level.
|
||||||
|
|
||||||
|
frameworks = {}
|
||||||
for framework in ['Tcl', 'Tk']:
|
for framework in ['Tcl', 'Tk']:
|
||||||
#fw = dict(lower=framework.lower(),
|
fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
|
||||||
# upper=framework.upper(),
|
|
||||||
# cap=framework.capitalize())
|
|
||||||
#fwpth = "Library/Frameworks/%(cap)s.framework/%(lower)sConfig.sh" % fw
|
|
||||||
fwpth = 'Library/Frameworks/Tcl.framework/Versions/Current'
|
|
||||||
sysfw = os.path.join(SDKPATH, 'System', fwpth)
|
sysfw = os.path.join(SDKPATH, 'System', fwpth)
|
||||||
libfw = os.path.join('/', fwpth)
|
libfw = os.path.join(SDKPATH, fwpth)
|
||||||
usrfw = os.path.join(os.getenv('HOME'), fwpth)
|
usrfw = os.path.join(os.getenv('HOME'), fwpth)
|
||||||
#version = "%(upper)s_VERSION" % fw
|
frameworks[framework] = os.readlink(sysfw)
|
||||||
|
if not os.path.exists(libfw):
|
||||||
|
fatal("Please install a link to a current %s %s as %s so "
|
||||||
|
"the user can override the system framework."
|
||||||
|
% (framework, frameworks[framework], libfw))
|
||||||
if os.readlink(libfw) != os.readlink(sysfw):
|
if os.readlink(libfw) != os.readlink(sysfw):
|
||||||
fatal("Version of %s must match %s" % (libfw, sysfw) )
|
fatal("Version of %s must match %s" % (libfw, sysfw) )
|
||||||
if os.path.exists(usrfw):
|
if os.path.exists(usrfw):
|
||||||
fatal("Please rename %s to avoid possible dynamic load issues."
|
fatal("Please rename %s to avoid possible dynamic load issues."
|
||||||
% usrfw)
|
% usrfw)
|
||||||
|
|
||||||
|
if frameworks['Tcl'] != frameworks['Tk']:
|
||||||
|
fatal("The Tcl and Tk frameworks are not the same version.")
|
||||||
|
|
||||||
|
# add files to check after build
|
||||||
|
EXPECTED_SHARED_LIBS['_tkinter.so'] = [
|
||||||
|
"/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
|
||||||
|
% frameworks['Tcl'],
|
||||||
|
"/Library/Frameworks/Tk.framework/Versions/%s/Tk"
|
||||||
|
% frameworks['Tk'],
|
||||||
|
]
|
||||||
|
|
||||||
# Remove inherited environment variables which might influence build
|
# Remove inherited environment variables which might influence build
|
||||||
environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_',
|
environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_',
|
||||||
'LD_', 'LIBRARY_', 'PATH', 'PYTHON']
|
'LD_', 'LIBRARY_', 'PATH', 'PYTHON']
|
||||||
|
|
@ -861,12 +881,12 @@ def buildPython():
|
||||||
frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
|
frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
|
||||||
gid = grp.getgrnam('admin').gr_gid
|
gid = grp.getgrnam('admin').gr_gid
|
||||||
|
|
||||||
|
shared_lib_error = False
|
||||||
for dirpath, dirnames, filenames in os.walk(frmDir):
|
for dirpath, dirnames, filenames in os.walk(frmDir):
|
||||||
for dn in dirnames:
|
for dn in dirnames:
|
||||||
os.chmod(os.path.join(dirpath, dn), STAT_0o775)
|
os.chmod(os.path.join(dirpath, dn), STAT_0o775)
|
||||||
os.chown(os.path.join(dirpath, dn), -1, gid)
|
os.chown(os.path.join(dirpath, dn), -1, gid)
|
||||||
|
|
||||||
|
|
||||||
for fn in filenames:
|
for fn in filenames:
|
||||||
if os.path.islink(fn):
|
if os.path.islink(fn):
|
||||||
continue
|
continue
|
||||||
|
|
@ -877,6 +897,19 @@ def buildPython():
|
||||||
os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP)
|
os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP)
|
||||||
os.chown(p, -1, gid)
|
os.chown(p, -1, gid)
|
||||||
|
|
||||||
|
if fn in EXPECTED_SHARED_LIBS:
|
||||||
|
# check to see that this file was linked with the
|
||||||
|
# expected library path and version
|
||||||
|
data = captureCommand("otool -L %s" % shellQuote(p))
|
||||||
|
for sl in EXPECTED_SHARED_LIBS[fn]:
|
||||||
|
if ("\t%s " % sl) not in data:
|
||||||
|
print("Expected shared lib %s was not linked with %s"
|
||||||
|
% (sl, p))
|
||||||
|
shared_lib_error = True
|
||||||
|
|
||||||
|
if shared_lib_error:
|
||||||
|
fatal("Unexpected shared library errors.")
|
||||||
|
|
||||||
if PYTHON_3:
|
if PYTHON_3:
|
||||||
LDVERSION=None
|
LDVERSION=None
|
||||||
VERSION=None
|
VERSION=None
|
||||||
|
|
|
||||||
|
|
@ -264,6 +264,8 @@ Tests
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Issue #14018: Fix OS X Tcl/Tk framework checking when using OS X SDKs.
|
||||||
|
|
||||||
- Issue #15431: Add _freeze_importlib project to regenerate importlib.h
|
- Issue #15431: Add _freeze_importlib project to regenerate importlib.h
|
||||||
on Windows. Patch by Kristján Valur Jónsson.
|
on Windows. Patch by Kristján Valur Jónsson.
|
||||||
|
|
||||||
|
|
|
||||||
4
setup.py
4
setup.py
|
|
@ -69,7 +69,9 @@ def is_macosx_sdk_path(path):
|
||||||
"""
|
"""
|
||||||
Returns True if 'path' can be located in an OSX SDK
|
Returns True if 'path' can be located in an OSX SDK
|
||||||
"""
|
"""
|
||||||
return (path.startswith('/usr/') and not path.startswith('/usr/local')) or path.startswith('/System/')
|
return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
|
||||||
|
or path.startswith('/System/')
|
||||||
|
or path.startswith('/Library/') )
|
||||||
|
|
||||||
def find_file(filename, std_dirs, paths):
|
def find_file(filename, std_dirs, paths):
|
||||||
"""Searches for the directory where a given file is located,
|
"""Searches for the directory where a given file is located,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue