nad0006 Mac/BuildScript/buildinstall.py: add options for deployment target and universal build type. Defaults are unchanged. New arguments: --dep-target=10.n --universal-archs=x where x = '32-bit' -> 2-way 32-bit (intel|ppc) [default] '64-bit' -> 2-way 64-bit (intel|ppc) 'all' -> 4-way universal APPLIES py3k, 3.0, trunk, 2.6 diff -r f2a5eccb2e59 Mac/BuildScript/build-installer.py --- Mac/BuildScript/build-installer.py Sat Feb 14 18:23:44 2009 -0800 +++ Mac/BuildScript/build-installer.py Sat Feb 14 21:08:02 2009 -0800 @@ -1,8 +1,9 @@ -#!/usr/bin/python2.3 +#!/usr/bin/python """ This script is used to build the "official unofficial" universal build on Mac OS X. It requires Mac OS X 10.4, Xcode 2.2 and the 10.4u SDK to do its -work. +work. 64-bit or four-way universal builds require at least OS X 10.5 and +the 10.5 SDK. Please ensure that this script keeps working with Python 2.3, to avoid bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4) @@ -68,7 +69,15 @@ SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk" #SDKPATH = "/" -ARCHLIST = ('i386', 'ppc',) +universal_opts_map = { '32-bit': ('i386', 'ppc',), + '64-bit': ('x86_64', 'ppc64',), + 'all': ('i386', 'ppc', 'x86_64', 'ppc64',) } + +UNIVERSALOPTS = tuple(universal_opts_map.keys()) + +UNIVERSALARCHS = '32-bit' + +ARCHLIST = universal_opts_map[UNIVERSALARCHS] # Source directory (asume we're in Mac/BuildScript) SRCDIR = os.path.dirname( @@ -77,6 +86,9 @@ os.path.abspath(__file__ )))) +# $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level +DEPTARGET = '10.3' + USAGE = textwrap.dedent("""\ Usage: build_python [options] @@ -87,12 +99,17 @@ --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r) --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r) --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r) + --dep-target=10.n OS X deployment target (default: %(DEPTARGET)r) + --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r) """)% globals() # Instructions for building libraries that are necessary for building a # batteries included python. -LIBRARY_RECIPES = [ +# [The recipes are defined here for convenience but instantiated later after +# command line options have been processed.] +def library_recipes(): + return [ dict( name="Bzip2 1.0.3", url="http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz", @@ -169,7 +186,7 @@ getVersion(), ), ), -] + ] # Instructions for building packages inside the .mpkg. @@ -322,14 +339,16 @@ """ Parse arguments and update global settings. """ - global WORKDIR, DEPSRC, SDKPATH, SRCDIR + global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET + global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST if args is None: args = sys.argv[1:] try: options, args = getopt.getopt(args, '?hb', - [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) + [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=', + 'dep-target=', 'universal-archs=']) except getopt.error, msg: print msg sys.exit(1) @@ -355,6 +374,16 @@ elif k in ('--src-dir',): SRCDIR=v + elif k in ('--dep-target', ): + DEPTARGET=v + + elif k in ('--universal-archs', ): + if v in UNIVERSALOPTS: + UNIVERSALARCHS = v + ARCHLIST = universal_opts_map[UNIVERSALARCHS] + else: + raise NotImplementedError, v + else: raise NotImplementedError, k @@ -368,6 +397,8 @@ print " * Build directory: ", WORKDIR print " * SDK location: ", SDKPATH print " * third-party source:", DEPSRC + print " * deployment target:", DEPTARGET + print " * universal architectures:", ARCHLIST print "" @@ -567,7 +598,7 @@ os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) os.makedirs(os.path.join(universal, 'usr', 'local', 'include')) - for recipe in LIBRARY_RECIPES: + for recipe in library_recipes(): buildRecipe(recipe, universal, ARCHLIST) @@ -587,6 +618,7 @@ print "Using local copy of %s"%(name,) else: + print "Did not find local copy of %s"%(name,) print "Downloading %s"%(novername,) downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( getFullVersion(), novername), sourceArchive) @@ -601,7 +633,7 @@ def buildPython(): - print "Building a universal python" + print "Building a universal python for %s architectures" % UNIVERSALARCHS buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') @@ -625,9 +657,13 @@ version = getVersion() print "Running configure..." - runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( - shellQuote(os.path.join(SRCDIR, 'configure')), - shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1], + runCommand("%s -C --enable-framework --enable-universalsdk=%s " + "--with-universal-archs=%s " + "LDFLAGS='-g -L%s/libraries/usr/local/lib' " + "OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( + shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH), + UNIVERSALARCHS, + shellQuote(WORKDIR)[1:-1], shellQuote(WORKDIR)[1:-1])) print "Running make" @@ -715,7 +751,7 @@ data = fileContents(inPath) data = data.replace('$FULL_VERSION', getFullVersion()) data = data.replace('$VERSION', getVersion()) - data = data.replace('$MACOSX_DEPLOYMENT_TARGET', '10.3 or later') + data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later'))) data = data.replace('$ARCHITECTURES', "i386, ppc") data = data.replace('$INSTALL_SIZE', installSize()) @@ -1019,7 +1055,7 @@ parseOptions() checkEnvironment() - os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.3' + os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET if os.path.exists(WORKDIR): shutil.rmtree(WORKDIR)