Lines Matching +full:build +full:- +full:with +full:- +full:python
1 #!/usr/bin/env python
3 This script is used to build "official" universal installers on macOS.
6 - support universal2 variant with arm64 and x86_64 archs
7 - enable clang optimizations when building on 10.15+
10 - 2.7 end-of-life issues:
11 - Python 3 installs now update the Current version link
12 in /Library/Frameworks/Python.framework/Versions
13 - fully support running under Python 3 as well as 2.7
14 - support building on newer macOS systems with SIP
15 - fully support building on macOS 10.9+
16 - support 10.6+ on best effort
17 - support bypassing docs build by supplying a prebuilt
18 docs html tarball in the third-party source library,
20 downloadable from python.org:
21 python-3.x.y-docs-html.tar.bz2
24 - support Intel 64-bit-only () and 32-bit-only installer builds
25 - build and use internal Tcl/Tk 8.6 for 10.6+ builds
26 - deprecate use of explicit SDK (--sdk-path=) since all but the oldest
31 supported with build-installer.
32 - use generic "gcc" as compiler (CC env var) rather than "gcc-4.2"
35 - test building with SDKROOT and DEVELOPER_DIR xcrun env variables
63 with open(plist, 'wb') as fp:
76 QUOTED_VALUE='quotes' -> str('quotes')
77 UNQUOTED_VALUE=noquotes -> str('noquotes')
84 raise RuntimeError("Cannot find variable %s" % variable[:-1])
107 _cache_getFullVersion = ln.split()[-1][1:-1]
111 FW_PREFIX = ["Library", "Frameworks", "Python.framework"]
112 FW_VERSION_PREFIX = "--undefined--" # initialized in parseOptions
113 FW_SSL_DIRECTORY = "--undefined--" # initialized in parseOptions
115 # The directory we'll use to create the build (will be erased and recreated)
118 # The directory we'll use to store third-party sources. Set this to something
119 # else if you don't want to re-fetch required libraries every time.
120 DEPSRC = os.path.join(WORKDIR, 'third-party')
121 DEPSRC = os.path.expanduser('~/Universal/other-sources')
124 '32-bit': ('i386', 'ppc',),
125 '64-bit': ('x86_64', 'ppc64',),
127 'intel-32': ('i386',),
128 'intel-64': ('x86_64',),
129 '3-way': ('ppc', 'i386', 'x86_64'),
133 '64-bit': '10.5',
134 '3-way': '10.5',
136 'intel-32': '10.4',
137 'intel-64': '10.5',
143 UNIVERSALARCHS = '32-bit'
154 # $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level
165 '10.4': ('gcc-4.0', 'g++-4.0'),
181 -? or -h: Show this message
182 -b DIR
183 --build-dir=DIR: Create build here (default: %(WORKDIR)r)
184 --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r)
185 --sdk-path=DIR: Location of the SDK (deprecated, use SDKROOT env variable)
186 --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r)
187 --dep-target=10.n macOS deployment target (default: %(DEPTARGET)r)
188 …--universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCH…
191 # Dict of object file names with shared library names to check after building.
192 # This is to ensure that we ended up dynamically linking with the shared
199 # Are we building and linking with our own copy of Tcl/TK?
207 # old versions of macOS due to build issues.
213 with open("Makefile", "r") as fp:
229 with open("Makefile", "w") as fp:
232 # List of names of third party software built with this installer.
237 # batteries included python.
245 # have much choice but to build our own copy here, too.
250 url="https://www.openssl.org/source/openssl-1.1.1u.tar.gz",
277 url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tcl%s-src.tar.gz"%(tcl_tk_ver,),
281 '--enable-shared',
282 '--enable-threads',
283 '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
289 …"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersio…
294 url="ftp://ftp.tcl.tk/pub/tcl//tcl8_6/tk%s-src.tar.gz"%(tcl_tk_ver,),
299 '--enable-aqua',
300 '--enable-shared',
301 '--enable-threads',
302 '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
307 …"TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.6'%(getVersio…
308 …"TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.6'%(getVersion(…
317 url="http://tukaani.org/xz/xz-5.2.3.tar.gz",
320 '--disable-dependency-tracking',
328 url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz",
331 "--enable-widec",
332 "--without-cxx",
333 "--without-cxx-binding",
334 "--without-ada",
335 "--without-curses-h",
336 "--enable-shared",
337 "--with-shared",
338 "--without-debug",
339 "--without-normal",
340 "--without-tests",
341 "--without-manpages",
342 "--datadir=/usr/share",
343 "--sysconfdir=/etc",
344 "--sharedstatedir=/usr/com",
345 "--with-terminfo-dirs=/usr/share/terminfo",
346 "--with-default-terminfo-dir=/usr/share/terminfo",
347 "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),),
350 ("ftp://ftp.invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2",
354 … && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.fr…
362 url="https://sqlite.org/2023/sqlite-autoconf-3420000.tar.gz",
364 extra_cflags=('-Os '
365 '-DSQLITE_ENABLE_FTS5 '
366 '-DSQLITE_ENABLE_FTS4 '
367 '-DSQLITE_ENABLE_FTS3_PARENTHESIS '
368 '-DSQLITE_ENABLE_RTREE '
369 '-DSQLITE_OMIT_AUTOINIT '
370 '-DSQLITE_TCL=0 '
373 '--enable-threadsafe',
374 '--enable-shared=no',
375 '--enable-static=yes',
376 '--disable-readline',
377 '--disable-dependency-tracking',
386 url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
391 '--includedir=/usr/local/include/db4',
402 # bpo-42235: The version check is pretty conservative, can be
413 long_name="Python Framework",
414 source="/Library/Frameworks/Python.framework",
416 This package installs Python.framework, that is the python
425 source="/Applications/Python %(VER)s",
427 This package installs IDLE (an interactive Python IDE),
428 Python Launcher and Build Applet (create application bundles
429 from python scripts).
438 long_name="UNIX command-line tools",
442 compatibility with older releases of Python. This package
443 is not necessary to use Python.
450 long_name="Python Documentation",
451 …topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentatio…
454 This package installs the python documentation at a location
466 the Python tools are found by your shell in preference of
467 the system provided Python tools.
470 "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin"
473 postflight="scripts/postflight.patch-profile",
474 topdir="/Library/Frameworks/Python.framework",
475 source="/empty-dir",
484 pip, a tool for installing and managing Python packages.
487 topdir="/Library/Frameworks/Python.framework",
488 source="/empty-dir",
559 fatal("This script must be run with Python 2.7 (or later)")
570 # 1. there is a user-installed framework (usually ActiveTcl) in (or linked
571 # in) SDKROOT/Library/Frameworks. As of Python 3.7.0, we no longer
572 # enforce that the version of the user-installed framework also
573 # exists in the system-supplied Tcl/Tk frameworks. Time to support
593 print(" -- Building with external Tcl/Tk %s frameworks"
596 # add files to check after build
604 print(" -- Building private copy of Tcl/Tk")
607 # Remove inherited environment variables which might influence build
609 'LD_', 'LIBRARY_', 'PATH', 'PYTHON']
642 [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=',
643 'dep-target=', 'universal-archs=', 'help' ])
654 if k in ('-h', '-?', '--help'):
658 elif k in ('-d', '--build-dir'):
661 elif k in ('--third-party',):
664 elif k in ('--sdk-path',):
665 print(" WARNING: --sdk-path is no longer supported")
667 elif k in ('--src-dir',):
670 elif k in ('--dep-target', ):
674 elif k in ('--universal-archs', ):
697 print("-- Settings:")
699 print(" * Build directory: %s" % WORKDIR)
700 print(" * Third-party source: %s" % DEPSRC)
706 print(" -- Building a Python %s framework at patch level %s"
719 the archive ends with "-src" but the uncompressed directory does not.
726 retval = os.path.basename(archiveName[:-7])
728 and retval.endswith('-src')):
729 retval = retval[:-4]
739 retval = os.path.basename(archiveName[:-8])
745 retval = os.path.basename(archiveName[:-4])
751 retval = os.path.basename(archiveName[:-4])
812 Special case build recipe for universal build of openssl.
814 The upstream OpenSSL build system does not directly support
815 OS X universal builds. We need to build each architecture
819 # OpenSSL fails to build with Xcode 2.5 (on OS X 10.4).
825 "Build one architecture of openssl"
827 "i386": ["darwin-i386-cc"],
828 "x86_64": ["darwin64-x86_64-cc", "enable-ec_nistp_64_gcc_128"],
829 "arm64": ["darwin64-arm64-cc"],
830 "ppc": ["darwin-ppc-cc"],
831 "ppc64": ["darwin64-ppc-cc"],
835 # "enable-ec_nistp_64_gcc_128" option to get compile errors when
836 # building on our 10.6 gcc-4.2 environment. There have been other
838 # So, for now, do not try to use "enable-ec_nistp_64_gcc_128" when
841 arch_opts['x86_64'].remove('enable-ec_nistp_64_gcc_128')
844 "no-idea",
845 "no-mdc2",
846 "no-rc5",
847 "no-zlib",
848 "no-ssl3",
849 # "enable-unit-test",
851 "--prefix=%s"%os.path.join("/", *FW_VERSION_PREFIX),
852 "--openssldir=%s"%os.path.join("/", *FW_SSL_DIRECTORY),
855 configure_opts.append("no-asm")
866 os.path.basename(srcdir) + "-universal")
876 # Python framework base within install_prefix:
877 # the build will install into this framework..
882 # build one architecture
888 # copy arch-independent files from last build into the basedir framework
897 # e.g. -> "1.0.0"
900 # e.g. -> "libcrypto.1.0.0.dylib"
903 # e.g. -> "libssl.1.0.0.dylib"
910 # merge the individual arch-dependent shared libs into a fat shared lib
916 runCommand("lipo -create -output " +
924 # into the Python build so that setup.py can find them while building
925 # and the versioned links so that the setup.py post-build import test
944 Build software using a recipe. This function does the
945 'configure;make;make install' dance for C software, with a possibility
946 to customize this process, basically a poor-mans DarwinPorts.
958 archiveName = os.path.split(url)[-1]
981 runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
993 runCommand('bunzip2 -fk %s' % shellQuote(fn))
994 fn = fn[:-4]
1003 "--prefix=/usr/local",
1004 "--enable-static",
1005 "--disable-shared",
1006 #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
1011 if '--disable-static' in args:
1012 configure_args.remove('--enable-static')
1013 if '--enable-shared' in args:
1014 configure_args.remove('--disable-shared')
1019 "CFLAGS=%s-mmacosx-version-min=%s -arch %s "
1020 "-I%s/usr/local/include"%(
1023 ' -arch '.join(archList),
1024 shellQuote(basedir)[1:-1],),
1025 "LDFLAGS=-mmacosx-version-min=%s -L%s/usr/local/lib -arch %s"%(
1027 shellQuote(basedir)[1:-1],
1028 ' -arch '.join(archList)),
1032 "CFLAGS=%s-mmacosx-version-min=%s -arch %s "
1033 "-I%s/usr/local/include"%(
1036 ' -arch '.join(archList),
1037 shellQuote(basedir)[1:-1],),
1050 # call special-case build recipe, e.g. for openssl
1064 Build our dependencies into $WORKDIR/libraries/usr/local
1082 print("Install python documentation")
1090 # Search third-party source directory for a pre-built version of the docs.
1091 # Use the naming convention of the docs.python.org html downloads:
1092 # python-3.9.0b1-docs-html.tar.bz2
1094 if f.startswith('python-'+getFullVersion())
1095 if f.endswith('-docs-html.tar.bz2') ]
1098 if not os.path.exists('build'):
1099 os.mkdir('build')
1100 # if build directory existed, it was emptied by make clean, above
1101 os.chdir('build')
1102 # Extract the first archive found for this version into build
1104 # see if tar extracted a directory ending in -docs-html
1106 if f.endswith('-docs-html')
1110 # make it our 'Docs/build/html' directory
1111 print(' -- using pre-built python documentation from %s'%archivefile)
1115 htmlDir = os.path.join('build', 'html')
1117 # Create virtual environment for docs builds with blurb and sphinx
1119 runCommand('make html PYTHON=venv/bin/python')
1125 print("Building a universal python for %s architectures" % UNIVERSALARCHS)
1127 buildDir = os.path.join(WORKDIR, '_bld', 'python')
1136 os.makedirs(os.path.join(rootDir, 'empty-dir'))
1145 # during the build, augment the library path so that the interpreter
1149 runCommand("%s -C --enable-framework --enable-universalsdk=/ "
1150 "--with-universal-archs=%s "
1157 "LDFLAGS='-g -L%s/libraries/usr/local/lib' "
1158 "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%(
1161 (' ', '--with-computed-gotos ')[PYTHON_3],
1162 (' ', '--without-ensurepip ')[PYTHON_3],
1163 (' ', "--with-openssl='%s/libraries/usr/local'"%(
1164 shellQuote(WORKDIR)[1:-1],))[PYTHON_3],
1165 (' ', "--enable-optimizations --with-lto")[compilerCanOptimize()],
1166 (' ', "TCLTK_CFLAGS='-I%s/libraries/usr/local/include'"%(
1167 shellQuote(WORKDIR)[1:-1],))[internalTk()],
1168 (' ', "TCLTK_LIBS='-L%s/libraries/usr/local/lib -ltcl8.6 -ltk8.6'"%(
1169 shellQuote(WORKDIR)[1:-1],))[internalTk()],
1170 shellQuote(WORKDIR)[1:-1],
1171 shellQuote(WORKDIR)[1:-1]))
1173 # As of macOS 10.11 with SYSTEM INTEGRITY PROTECTION, DYLD_*
1176 # DYLD_LIBRARY_PATH, pointing to the third-party libs,
1177 # in build-installer.py's process environment and it was
1193 # us to pass in version control tags, like GITTAG, to a build from a
1195 # to have a working copy of the vcs program on the build machine.
1227 'Python.framework', 'Versions', getVersion(), 'lib')
1230 'Python.framework', 'Versions', getVersion(), 'lib')
1236 runCommand("rm -r %s/pkgconfig"%(
1242 frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
1244 path_to_lib = os.path.join(frmDirVersioned, 'lib', 'python%s'%(version,))
1256 os.chown(os.path.join(dirpath, dn), -1, gid)
1266 os.chown(p, -1, gid)
1269 # check to see that this file was linked with the
1271 data = captureCommand("otool -L %s" % shellQuote(p))
1274 print("Expected shared lib %s was not linked with %s"
1299 config_suffix = '-' + LDVERSION
1301 config_suffix = config_suffix + '-darwin'
1303 config_suffix = '' # Python 2.x
1307 # the end-users system. Also remove the directories from _sysconfigdata.py
1310 include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,)
1311 lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,)
1335 # pprint from the Python running the installer build which
1336 # may not cosmetically format the same as the pprint in the Python
1342 # XXX this is extra-fragile
1377 'Python.framework', 'Versions', version, 'bin')
1398 data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework')
1419 # because having two version of python installed at the same time is
1421 pkgname = '%s-%s'%(recipe['name'], getVersion())
1428 print("- building package %s"%(pkgname,))
1454 … runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),))
1455 … runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),))
1475 CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,),
1476 CFBundleIdentifier='org.python.Python.%s'%(pkgname,),
1477 CFBundleName='Python.%s'%(pkgname,),
1498 IFPkgDescriptionTitle=recipe.get('long_name', "Python.%s"%(pkgname,)),
1513 CFBundleGetInfoString="Python %s"%(vers,),
1514 CFBundleIdentifier='org.python.Python',
1515 CFBundleName='Python',
1522 IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()),
1549 pkgroot = os.path.join(outdir, 'Python.mpkg', 'Contents')
1566 IFPkgDescriptionTitle="Python",
1583 data = captureCommand("du -ks %s"%(
1598 # installer file name. With the introduction of weaklinked installer
1599 # variants, we may have two variants with the same file name, i.e.
1615 # python-3.x.y-macosx10.z.{dmg->pkg}
1616 # e.g. python-3.9.4-macosx10.9.{dmg->pkg}
1618 # python-3.x.y-macosz.{dmg->pkg}
1619 # e.g. python-3.9.4-macos11.{dmg->pkg}
1629 'python-%s-%s%s'%(getFullVersion(),os_name,build_system_version))
1631 imagepath = imagepath + '-%04d-%02d-%02d'%(time.localtime()[:3])
1637 # when hdiutil create fails with "Resource busy". For now, just retry
1640 volname='Python %s'%(getFullVersion())
1641 cmd = ("hdiutil create -format UDRW -volname %s -srcfolder %s -size 100m %s"%(
1652 print(" -- retrying hdiutil create")
1659 runCommand("hdiutil attach %s -mountroot %s"%(
1665 runCommand("SetFile -a C %s/"%(
1671 runCommand("hdiutil convert %s -format UDZO -o %s"%(
1693 runCommand("cc -o %s %s/seticon.m -framework Cocoa"%(
1714 # Then build third-party libraries such as sleepycat DB4.
1717 # Now build python itself
1720 # And then build the documentation
1723 # an unexpected build target can cause problems
1725 # be (re-)installed.
1731 folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%(
1738 patchScript("scripts/postflight.patch-profile", fn)
1742 setIcon(folder, "../Icons/Python Folder.icns")
1755 fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
1756 fp.write("# BUILD INFO\n")