Skip to content
Merged
Prev Previous commit
Next Next commit
Update macOS build-installer script with 3.9/3.10 changes
  • Loading branch information
ned-deily committed Apr 29, 2021
commit df7dcab54685f04099ac5b0946a34c674825eac6
103 changes: 88 additions & 15 deletions Mac/BuildScript/build-installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def getFullVersion():
def getDeptargetTuple():
return tuple([int(n) for n in DEPTARGET.split('.')[0:2]])

def getBuildTuple():
return tuple([int(n) for n in platform.mac_ver()[0].split('.')[0:2]])

def getTargetCompilers():
target_cc_map = {
'10.4': ('gcc-4.0', 'g++-4.0'),
Expand Down Expand Up @@ -192,6 +195,34 @@ def getTargetCompilers():
def internalTk():
return getDeptargetTuple() >= (10, 6)

# Do we use 8.6.8 when building our own copy
# of Tcl/Tk or a modern version.
# We use the old version when buildin on
# old versions of macOS due to build issues.
def useOldTk():
return getBuildTuple() < (10, 15)


def tweak_tcl_build(basedir, archList):
with open("Makefile", "r") as fp:
contents = fp.readlines()

# For reasons I don't understand the tcl configure script
# decides that some stdlib symbols aren't present, before
# deciding that strtod is broken.
new_contents = []
for line in contents:
if line.startswith("COMPAT_OBJS"):
# note: the space before strtod.o is intentional,
# the detection of a broken strtod results in
# "fixstrod.o" on this line.
for nm in ("strstr.o", "strtoul.o", " strtod.o"):
line = line.replace(nm, "")
new_contents.append(line)

with open("Makefile", "w") as fp:
fp.writelines(new_contents)

# List of names of third party software built with this installer.
# The names will be inserted into the rtf version of the License.
THIRD_PARTY_LIBS = []
Expand Down Expand Up @@ -221,30 +252,44 @@ def library_recipes():
])

if internalTk():
if useOldTk():
tcl_tk_ver='8.6.8'
tcl_checksum='81656d3367af032e0ae6157eff134f89'

tk_checksum='5e0faecba458ee1386078fb228d008ba'
tk_patches = ['tk868_on_10_8_10_9.patch']

else:
tcl_tk_ver='8.6.11'
tcl_checksum='8a4c004f48984a03a7747e9ba06e4da4'

tk_checksum='c7ee71a2d05bba78dfffd76528dc17c6'
tk_patches = [ ]


result.extend([
dict(
name="Tcl 8.6.8",
url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl8.6.8-src.tar.gz",
checksum='81656d3367af032e0ae6157eff134f89',
name="Tcl %s"%(tcl_tk_ver,),
url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl%s-src.tar.gz"%(tcl_tk_ver,),
checksum=tcl_checksum,
buildDir="unix",
configure_pre=[
'--enable-shared',
'--enable-threads',
'--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
],
useLDFlags=False,
buildrecipe=tweak_tcl_build,
install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
"DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersion())),
},
),
dict(
name="Tk 8.6.8",
url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk8.6.8-src.tar.gz",
checksum='5e0faecba458ee1386078fb228d008ba',
patches=[
"tk868_on_10_8_10_9.patch",
],
name="Tk %s"%(tcl_tk_ver,),
url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk%s-src.tar.gz"%(tcl_tk_ver,),
checksum=tk_checksum,
patches=tk_patches,
buildDir="unix",
configure_pre=[
'--enable-aqua',
Expand Down Expand Up @@ -539,8 +584,8 @@ def checkEnvironment():
Check that we're running on a supported system.
"""

if sys.version_info[0:2] < (2, 5):
fatal("This script must be run with Python 2.5 (or later)")
if sys.version_info[0:2] < (2, 7):
fatal("This script must be run with Python 2.7 (or later)")

if platform.system() != 'Darwin':
fatal("This script should be run on a macOS 10.5 (or later) system")
Expand Down Expand Up @@ -608,9 +653,6 @@ def checkEnvironment():
base_path = base_path + ':' + OLD_DEVELOPER_TOOLS
os.environ['PATH'] = base_path
print("Setting default PATH: %s"%(os.environ['PATH']))
# Ensure we have access to sphinx-build.
# You may have to create a link in /usr/bin for it.
runCommand('sphinx-build --version')

def parseOptions(args=None):
"""
Expand Down Expand Up @@ -1569,8 +1611,39 @@ def buildDMG():
if os.path.exists(outdir):
shutil.rmtree(outdir)

# We used to use the deployment target as the last characters of the
# installer file name. With the introduction of weaklinked installer
# variants, we may have two variants with the same file name, i.e.
# both ending in '10.9'. To avoid this, we now use the major/minor
# version numbers of the macOS version we are building on.
# Also, as of macOS 11, operating system version numbering has
# changed from three components to two, i.e.
# 10.14.1, 10.14.2, ...
# 10.15.1, 10.15.2, ...
# 11.1, 11.2, ...
# 12.1, 12.2, ...
# (A further twist is that, when running on macOS 11, binaries built
# on older systems may be shown an operating system version of 10.16
# instead of 11. We should not run into that situation here.)
# Also we should use "macos" instead of "macosx" going forward.
#
# To maintain compability for legacy variants, the file name for
# builds on macOS 10.15 and earlier remains:
# python-3.x.y-macosx10.z.{dmg->pkg}
# e.g. python-3.9.4-macosx10.9.{dmg->pkg}
# and for builds on macOS 11+:
# python-3.x.y-macosz.{dmg->pkg}
# e.g. python-3.9.4-macos11.{dmg->pkg}

build_tuple = getBuildTuple()
if build_tuple[0] < 11:
os_name = 'macosx'
build_system_version = '%s.%s' % build_tuple
else:
os_name = 'macos'
build_system_version = str(build_tuple[0])
imagepath = os.path.join(outdir,
'python-%s-macosx%s'%(getFullVersion(),DEPTARGET))
'python-%s-%s%s'%(getFullVersion(),os_name,build_system_version))
if INCLUDE_TIMESTAMP:
imagepath = imagepath + '-%04d-%02d-%02d'%(time.localtime()[:3])
imagepath = imagepath + '.dmg'
Expand Down