bpo-32726: Build macOS 10.9+ installer with private copy of Tcl/Tk 8.6 · python/cpython@7fdefac
@@ -189,6 +189,11 @@ def getTargetCompilers():
189189# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk']
190190EXPECTED_SHARED_LIBS = {}
191191192+# Are we building and linking with our own copy of Tcl/TK?
193+# For now, do so if deployment target is 10.9+.
194+def internalTk():
195+return getDeptargetTuple() >= (10, 9)
196+192197# List of names of third party software built with this installer.
193198# The names will be inserted into the rtf version of the License.
194199THIRD_PARTY_LIBS = []
@@ -217,13 +222,12 @@ def library_recipes():
217222 ),
218223 ])
219224220-# Disable for now
221-if False: # if getDeptargetTuple() > (10, 5):
225+if internalTk():
222226result.extend([
223227dict(
224-name="Tcl 8.5.15",
225-url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tcl8.5.15-src.tar.gz",
226-checksum='f3df162f92c69b254079c4d0af7a690f',
228+name="Tcl 8.6.7",
229+url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl8.6.7-src.tar.gz",
230+checksum='5673aaf45b5de5d8dd80bb3daaeb8838',
227231buildDir="unix",
228232configure_pre=[
229233'--enable-shared',
@@ -233,16 +237,13 @@ def library_recipes():
233237useLDFlags=False,
234238install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
235239"DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
236-"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
240+"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersion())),
237241 },
238242 ),
239243dict(
240-name="Tk 8.5.15",
241-url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tk8.5.15-src.tar.gz",
242-checksum='55b8e33f903210a4e1c8bce0f820657f',
243-patches=[
244-"issue19373_tk_8_5_15_source.patch",
245- ],
244+name="Tk 8.6.7",
245+url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk8.6.7-src.tar.gz",
246+checksum='46ea9c0165c515d87393700f4891ab6f',
246247buildDir="unix",
247248configure_pre=[
248249'--enable-aqua',
@@ -253,8 +254,8 @@ def library_recipes():
253254useLDFlags=False,
254255install='make TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s TK_LIBRARY=%(TK_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
255256"DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
256-"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
257-"TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.5'%(getVersion())),
257+"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersion())),
258+"TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.6'%(getVersion())),
258259 },
259260 ),
260261 ])
@@ -547,42 +548,45 @@ def checkEnvironment():
547548fatal("This script should be run on a macOS 10.5 (or later) system")
548549549550# Because we only support dynamic load of only one major/minor version of
551+# Tcl/Tk, if we are not using building and using our own private copy of
550552# Tcl/Tk, ensure:
551553# 1. there is a user-installed framework (usually ActiveTcl) in (or linked
552554# in) SDKROOT/Library/Frameworks. As of Python 3.7.0, we no longer
553555# enforce that the version of the user-installed framework also
554556# exists in the system-supplied Tcl/Tk frameworks. Time to support
555557# Tcl/Tk 8.6 even if Apple does not.
556-557-frameworks = {}
558-for framework in ['Tcl', 'Tk']:
559-fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
560-libfw = os.path.join('/', fwpth)
561-usrfw = os.path.join(os.getenv('HOME'), fwpth)
562-frameworks[framework] = os.readlink(libfw)
563-if not os.path.exists(libfw):
564-fatal("Please install a link to a current %s %s as %s so "
565-"the user can override the system framework."
566-% (framework, frameworks[framework], libfw))
567-if os.path.exists(usrfw):
568-fatal("Please rename %s to avoid possible dynamic load issues."
569-% usrfw)
570-571-if frameworks['Tcl'] != frameworks['Tk']:
572-fatal("The Tcl and Tk frameworks are not the same version.")
573-574-print(" -- Building with Tcl/Tk %s frameworks"
575-% frameworks['Tk'])
558+if not internalTk():
559+frameworks = {}
560+for framework in ['Tcl', 'Tk']:
561+fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
562+libfw = os.path.join('/', fwpth)
563+usrfw = os.path.join(os.getenv('HOME'), fwpth)
564+frameworks[framework] = os.readlink(libfw)
565+if not os.path.exists(libfw):
566+fatal("Please install a link to a current %s %s as %s so "
567+"the user can override the system framework."
568+% (framework, frameworks[framework], libfw))
569+if os.path.exists(usrfw):
570+fatal("Please rename %s to avoid possible dynamic load issues."
571+% usrfw)
572+573+if frameworks['Tcl'] != frameworks['Tk']:
574+fatal("The Tcl and Tk frameworks are not the same version.")
575+576+print(" -- Building with external Tcl/Tk %s frameworks"
577+% frameworks['Tk'])
578+579+# add files to check after build
580+EXPECTED_SHARED_LIBS['_tkinter.so'] = [
581+"/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
582+% frameworks['Tcl'],
583+"/Library/Frameworks/Tk.framework/Versions/%s/Tk"
584+% frameworks['Tk'],
585+ ]
586+else:
587+print(" -- Building private copy of Tcl/Tk")
576588print("")
577589578-# add files to check after build
579-EXPECTED_SHARED_LIBS['_tkinter.so'] = [
580-"/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
581-% frameworks['Tcl'],
582-"/Library/Frameworks/Tk.framework/Versions/%s/Tk"
583-% frameworks['Tk'],
584- ]
585-586590# Remove inherited environment variables which might influence build
587591environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_',
588592'LD_', 'LIBRARY_', 'PATH', 'PYTHON']
@@ -1086,12 +1090,18 @@ def buildPython():
10861090"--with-universal-archs=%s "
10871091"%s "
10881092"%s "
1093+"%s "
1094+"%s "
10891095"LDFLAGS='-g -L%s/libraries/usr/local/lib' "
10901096"CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%(
10911097shellQuote(os.path.join(SRCDIR, 'configure')),
10921098UNIVERSALARCHS,
10931099 (' ', '--with-computed-gotos ')[PYTHON_3],
10941100 (' ', '--without-ensurepip ')[PYTHON_3],
1101+ (' ', "--with-tcltk-includes='-I%s/libraries/usr/local/include'"%(
1102+shellQuote(WORKDIR)[1:-1],))[internalTk()],
1103+ (' ', "--with-tcltk-libs='-L%s/libraries/usr/local/lib -ltcl8.6 -ltk8.6'"%(
1104+shellQuote(WORKDIR)[1:-1],))[internalTk()],
10951105shellQuote(WORKDIR)[1:-1],
10961106shellQuote(WORKDIR)[1:-1]))
10971107@@ -1126,14 +1136,22 @@ def buildPython():
11261136del os.environ['DYLD_LIBRARY_PATH']
11271137print("Copying required shared libraries")
11281138if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
1129-runCommand("mv %s/* %s"%(
1130-shellQuote(os.path.join(
1139+build_lib_dir = os.path.join(
11311140WORKDIR, 'libraries', 'Library', 'Frameworks',
1132-'Python.framework', 'Versions', getVersion(),
1133-'lib')),
1134-shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks',
1135-'Python.framework', 'Versions', getVersion(),
1136-'lib'))))
1141+'Python.framework', 'Versions', getVersion(), 'lib')
1142+fw_lib_dir = os.path.join(
1143+WORKDIR, '_root', 'Library', 'Frameworks',
1144+'Python.framework', 'Versions', getVersion(), 'lib')
1145+if internalTk():
1146+# move Tcl and Tk pkgconfig files
1147+runCommand("mv %s/pkgconfig/* %s/pkgconfig"%(
1148+shellQuote(build_lib_dir),
1149+shellQuote(fw_lib_dir) ))
1150+runCommand("rm -r %s/pkgconfig"%(
1151+shellQuote(build_lib_dir), ))
1152+runCommand("mv %s/* %s"%(
1153+shellQuote(build_lib_dir),
1154+shellQuote(fw_lib_dir) ))
1137115511381156frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
11391157frmDirVersioned = os.path.join(frmDir, 'Versions', version)