ยปCore Development>Code coverage>Mac/BuildScript/build-installer.py

Python code coverage for Mac/BuildScript/build-installer.py

#countcontent
1n/a#!/usr/bin/env python
2n/a"""
3n/aThis script is used to build "official" universal installers on Mac OS X.
4n/aIt requires at least Mac OS X 10.5, Xcode 3, and the 10.4u SDK for
5n/a32-bit builds. 64-bit or four-way universal builds require at least
6n/aOS X 10.5 and the 10.5 SDK.
7n/a
8n/aPlease ensure that this script keeps working with Python 2.5, to avoid
9n/abootstrap issues (/usr/bin/python is Python 2.5 on OSX 10.5). Sphinx,
10n/awhich is used to build the documentation, currently requires at least
11n/aPython 2.4. However, as of Python 3.4.1, Doc builds require an external
12n/asphinx-build and the current versions of Sphinx now require at least
13n/aPython 2.6.
14n/a
15n/aIn addition to what is supplied with OS X 10.5+ and Xcode 3+, the script
16n/arequires an installed version of hg and a third-party version of
17n/aTcl/Tk 8.4 (for OS X 10.4 and 10.5 deployment targets) or Tcl/TK 8.5
18n/a(for 10.6 or later) installed in /Library/Frameworks. When installed,
19n/athe Python built by this script will attempt to dynamically link first to
20n/aTcl and Tk frameworks in /Library/Frameworks if available otherwise fall
21n/aback to the ones in /System/Library/Framework. For the build, we recommend
22n/ainstalling the most recent ActiveTcl 8.4 or 8.5 version.
23n/a
24n/a32-bit-only installer builds are still possible on OS X 10.4 with Xcode 2.5
25n/aand the installation of additional components, such as a newer Python
26n/a(2.5 is needed for Python parser updates), hg, and for the documentation
27n/abuild either svn (pre-3.4.1) or sphinx-build (3.4.1 and later).
28n/a
29n/aUsage: see USAGE variable in the script.
30n/a"""
31n/aimport platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp
32n/atry:
33n/a import urllib2 as urllib_request
34n/aexcept ImportError:
35n/a import urllib.request as urllib_request
36n/a
37n/aSTAT_0o755 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
38n/a | stat.S_IRGRP | stat.S_IXGRP
39n/a | stat.S_IROTH | stat.S_IXOTH )
40n/a
41n/aSTAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
42n/a | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
43n/a | stat.S_IROTH | stat.S_IXOTH )
44n/a
45n/aINCLUDE_TIMESTAMP = 1
46n/aVERBOSE = 1
47n/a
48n/afrom plistlib import Plist
49n/a
50n/atry:
51n/a from plistlib import writePlist
52n/aexcept ImportError:
53n/a # We're run using python2.3
54n/a def writePlist(plist, path):
55n/a plist.write(path)
56n/a
57n/adef shellQuote(value):
58n/a """
59n/a Return the string value in a form that can safely be inserted into
60n/a a shell command.
61n/a """
62n/a return "'%s'"%(value.replace("'", "'\"'\"'"))
63n/a
64n/adef grepValue(fn, variable):
65n/a """
66n/a Return the unquoted value of a variable from a file..
67n/a QUOTED_VALUE='quotes' -> str('quotes')
68n/a UNQUOTED_VALUE=noquotes -> str('noquotes')
69n/a """
70n/a variable = variable + '='
71n/a for ln in open(fn, 'r'):
72n/a if ln.startswith(variable):
73n/a value = ln[len(variable):].strip()
74n/a return value.strip("\"'")
75n/a raise RuntimeError("Cannot find variable %s" % variable[:-1])
76n/a
77n/a_cache_getVersion = None
78n/a
79n/adef getVersion():
80n/a global _cache_getVersion
81n/a if _cache_getVersion is None:
82n/a _cache_getVersion = grepValue(
83n/a os.path.join(SRCDIR, 'configure'), 'PACKAGE_VERSION')
84n/a return _cache_getVersion
85n/a
86n/adef getVersionMajorMinor():
87n/a return tuple([int(n) for n in getVersion().split('.', 2)])
88n/a
89n/a_cache_getFullVersion = None
90n/a
91n/adef getFullVersion():
92n/a global _cache_getFullVersion
93n/a if _cache_getFullVersion is not None:
94n/a return _cache_getFullVersion
95n/a fn = os.path.join(SRCDIR, 'Include', 'patchlevel.h')
96n/a for ln in open(fn):
97n/a if 'PY_VERSION' in ln:
98n/a _cache_getFullVersion = ln.split()[-1][1:-1]
99n/a return _cache_getFullVersion
100n/a raise RuntimeError("Cannot find full version??")
101n/a
102n/aFW_PREFIX = ["Library", "Frameworks", "Python.framework"]
103n/aFW_VERSION_PREFIX = "--undefined--" # initialized in parseOptions
104n/aFW_SSL_DIRECTORY = "--undefined--" # initialized in parseOptions
105n/a
106n/a# The directory we'll use to create the build (will be erased and recreated)
107n/aWORKDIR = "/tmp/_py"
108n/a
109n/a# The directory we'll use to store third-party sources. Set this to something
110n/a# else if you don't want to re-fetch required libraries every time.
111n/aDEPSRC = os.path.join(WORKDIR, 'third-party')
112n/aDEPSRC = os.path.expanduser('~/Universal/other-sources')
113n/a
114n/a# Location of the preferred SDK
115n/a
116n/a### There are some issues with the SDK selection below here,
117n/a### The resulting binary doesn't work on all platforms that
118n/a### it should. Always default to the 10.4u SDK until that
119n/a### issue is resolved.
120n/a###
121n/a##if int(os.uname()[2].split('.')[0]) == 8:
122n/a## # Explicitly use the 10.4u (universal) SDK when
123n/a## # building on 10.4, the system headers are not
124n/a## # useable for a universal build
125n/a## SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk"
126n/a##else:
127n/a## SDKPATH = "/"
128n/a
129n/aSDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk"
130n/a
131n/auniversal_opts_map = { '32-bit': ('i386', 'ppc',),
132n/a '64-bit': ('x86_64', 'ppc64',),
133n/a 'intel': ('i386', 'x86_64'),
134n/a '3-way': ('ppc', 'i386', 'x86_64'),
135n/a 'all': ('i386', 'ppc', 'x86_64', 'ppc64',) }
136n/adefault_target_map = {
137n/a '64-bit': '10.5',
138n/a '3-way': '10.5',
139n/a 'intel': '10.5',
140n/a 'all': '10.5',
141n/a}
142n/a
143n/aUNIVERSALOPTS = tuple(universal_opts_map.keys())
144n/a
145n/aUNIVERSALARCHS = '32-bit'
146n/a
147n/aARCHLIST = universal_opts_map[UNIVERSALARCHS]
148n/a
149n/a# Source directory (assume we're in Mac/BuildScript)
150n/aSRCDIR = os.path.dirname(
151n/a os.path.dirname(
152n/a os.path.dirname(
153n/a os.path.abspath(__file__
154n/a ))))
155n/a
156n/a# $MACOSX_DEPLOYMENT_TARGET -> minimum OS X level
157n/aDEPTARGET = '10.3'
158n/a
159n/adef getDeptargetTuple():
160n/a return tuple([int(n) for n in DEPTARGET.split('.')[0:2]])
161n/a
162n/adef getTargetCompilers():
163n/a target_cc_map = {
164n/a '10.3': ('gcc-4.0', 'g++-4.0'),
165n/a '10.4': ('gcc-4.0', 'g++-4.0'),
166n/a '10.5': ('gcc-4.2', 'g++-4.2'),
167n/a '10.6': ('gcc-4.2', 'g++-4.2'),
168n/a }
169n/a return target_cc_map.get(DEPTARGET, ('clang', 'clang++') )
170n/a
171n/aCC, CXX = getTargetCompilers()
172n/a
173n/aPYTHON_3 = getVersionMajorMinor() >= (3, 0)
174n/a
175n/aUSAGE = textwrap.dedent("""\
176n/a Usage: build_python [options]
177n/a
178n/a Options:
179n/a -? or -h: Show this message
180n/a -b DIR
181n/a --build-dir=DIR: Create build here (default: %(WORKDIR)r)
182n/a --third-party=DIR: Store third-party sources here (default: %(DEPSRC)r)
183n/a --sdk-path=DIR: Location of the SDK (default: %(SDKPATH)r)
184n/a --src-dir=DIR: Location of the Python sources (default: %(SRCDIR)r)
185n/a --dep-target=10.n OS X deployment target (default: %(DEPTARGET)r)
186n/a --universal-archs=x universal architectures (options: %(UNIVERSALOPTS)r, default: %(UNIVERSALARCHS)r)
187n/a""")% globals()
188n/a
189n/a# Dict of object file names with shared library names to check after building.
190n/a# This is to ensure that we ended up dynamically linking with the shared
191n/a# library paths and versions we expected. For example:
192n/a# EXPECTED_SHARED_LIBS['_tkinter.so'] = [
193n/a# '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl',
194n/a# '/Library/Frameworks/Tk.framework/Versions/8.5/Tk']
195n/aEXPECTED_SHARED_LIBS = {}
196n/a
197n/a# List of names of third party software built with this installer.
198n/a# The names will be inserted into the rtf version of the License.
199n/aTHIRD_PARTY_LIBS = []
200n/a
201n/a# Instructions for building libraries that are necessary for building a
202n/a# batteries included python.
203n/a# [The recipes are defined here for convenience but instantiated later after
204n/a# command line options have been processed.]
205n/adef library_recipes():
206n/a result = []
207n/a
208n/a LT_10_5 = bool(getDeptargetTuple() < (10, 5))
209n/a
210n/a # Since Apple removed the header files for the deprecated system
211n/a # OpenSSL as of the Xcode 7 release (for OS X 10.10+), we do not
212n/a # have much choice but to build our own copy here, too.
213n/a
214n/a result.extend([
215n/a dict(
216n/a name="OpenSSL 1.0.2j",
217n/a url="https://www.openssl.org/source/openssl-1.0.2j.tar.gz",
218n/a checksum='96322138f0b69e61b7212bc53d5e912b',
219n/a patches=[
220n/a "openssl_sdk_makedepend.patch",
221n/a ],
222n/a buildrecipe=build_universal_openssl,
223n/a configure=None,
224n/a install=None,
225n/a ),
226n/a ])
227n/a
228n/a# Disable for now
229n/a if False: # if getDeptargetTuple() > (10, 5):
230n/a result.extend([
231n/a dict(
232n/a name="Tcl 8.5.15",
233n/a url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tcl8.5.15-src.tar.gz",
234n/a checksum='f3df162f92c69b254079c4d0af7a690f',
235n/a buildDir="unix",
236n/a configure_pre=[
237n/a '--enable-shared',
238n/a '--enable-threads',
239n/a '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
240n/a ],
241n/a useLDFlags=False,
242n/a install='make TCL_LIBRARY=%(TCL_LIBRARY)s && make install TCL_LIBRARY=%(TCL_LIBRARY)s DESTDIR=%(DESTDIR)s'%{
243n/a "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
244n/a "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
245n/a },
246n/a ),
247n/a dict(
248n/a name="Tk 8.5.15",
249n/a url="ftp://ftp.tcl.tk/pub/tcl//tcl8_5/tk8.5.15-src.tar.gz",
250n/a checksum='55b8e33f903210a4e1c8bce0f820657f',
251n/a patches=[
252n/a "issue19373_tk_8_5_15_source.patch",
253n/a ],
254n/a buildDir="unix",
255n/a configure_pre=[
256n/a '--enable-aqua',
257n/a '--enable-shared',
258n/a '--enable-threads',
259n/a '--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib'%(getVersion(),),
260n/a ],
261n/a useLDFlags=False,
262n/a install='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'%{
263n/a "DESTDIR": shellQuote(os.path.join(WORKDIR, 'libraries')),
264n/a "TCL_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tcl8.5'%(getVersion())),
265n/a "TK_LIBRARY": shellQuote('/Library/Frameworks/Python.framework/Versions/%s/lib/tk8.5'%(getVersion())),
266n/a },
267n/a ),
268n/a ])
269n/a
270n/a if PYTHON_3:
271n/a result.extend([
272n/a dict(
273n/a name="XZ 5.2.2",
274n/a url="http://tukaani.org/xz/xz-5.2.2.tar.gz",
275n/a checksum='7cf6a8544a7dae8e8106fdf7addfa28c',
276n/a configure_pre=[
277n/a '--disable-dependency-tracking',
278n/a ]
279n/a ),
280n/a ])
281n/a
282n/a result.extend([
283n/a dict(
284n/a name="NCurses 5.9",
285n/a url="http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz",
286n/a checksum='8cb9c412e5f2d96bc6f459aa8c6282a1',
287n/a configure_pre=[
288n/a "--enable-widec",
289n/a "--without-cxx",
290n/a "--without-cxx-binding",
291n/a "--without-ada",
292n/a "--without-curses-h",
293n/a "--enable-shared",
294n/a "--with-shared",
295n/a "--without-debug",
296n/a "--without-normal",
297n/a "--without-tests",
298n/a "--without-manpages",
299n/a "--datadir=/usr/share",
300n/a "--sysconfdir=/etc",
301n/a "--sharedstatedir=/usr/com",
302n/a "--with-terminfo-dirs=/usr/share/terminfo",
303n/a "--with-default-terminfo-dir=/usr/share/terminfo",
304n/a "--libdir=/Library/Frameworks/Python.framework/Versions/%s/lib"%(getVersion(),),
305n/a ],
306n/a patchscripts=[
307n/a ("ftp://invisible-island.net/ncurses//5.9/ncurses-5.9-20120616-patch.sh.bz2",
308n/a "f54bf02a349f96a7c4f0d00922f3a0d4"),
309n/a ],
310n/a useLDFlags=False,
311n/a install='make && make install DESTDIR=%s && cd %s/usr/local/lib && ln -fs ../../../Library/Frameworks/Python.framework/Versions/%s/lib/lib* .'%(
312n/a shellQuote(os.path.join(WORKDIR, 'libraries')),
313n/a shellQuote(os.path.join(WORKDIR, 'libraries')),
314n/a getVersion(),
315n/a ),
316n/a ),
317n/a dict(
318n/a name="SQLite 3.14.2",
319n/a url="https://www.sqlite.org/2016/sqlite-autoconf-3140200.tar.gz",
320n/a checksum='90c53cacb811db27f990b8292bd96159',
321n/a extra_cflags=('-Os '
322n/a '-DSQLITE_ENABLE_FTS5 '
323n/a '-DSQLITE_ENABLE_FTS4 '
324n/a '-DSQLITE_ENABLE_FTS3_PARENTHESIS '
325n/a '-DSQLITE_ENABLE_RTREE '
326n/a '-DSQLITE_TCL=0 '
327n/a '%s' % ('','-DSQLITE_WITHOUT_ZONEMALLOC ')[LT_10_5]),
328n/a configure_pre=[
329n/a '--enable-threadsafe',
330n/a '--enable-shared=no',
331n/a '--enable-static=yes',
332n/a '--disable-readline',
333n/a '--disable-dependency-tracking',
334n/a ]
335n/a ),
336n/a ])
337n/a
338n/a if getDeptargetTuple() < (10, 5):
339n/a result.extend([
340n/a dict(
341n/a name="Bzip2 1.0.6",
342n/a url="http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz",
343n/a checksum='00b516f4704d4a7cb50a1d97e6e8e15b',
344n/a configure=None,
345n/a install='make install CC=%s CXX=%s, PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
346n/a CC, CXX,
347n/a shellQuote(os.path.join(WORKDIR, 'libraries')),
348n/a ' -arch '.join(ARCHLIST),
349n/a SDKPATH,
350n/a ),
351n/a ),
352n/a dict(
353n/a name="ZLib 1.2.3",
354n/a url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz",
355n/a checksum='debc62758716a169df9f62e6ab2bc634',
356n/a configure=None,
357n/a install='make install CC=%s CXX=%s, prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
358n/a CC, CXX,
359n/a shellQuote(os.path.join(WORKDIR, 'libraries')),
360n/a ' -arch '.join(ARCHLIST),
361n/a SDKPATH,
362n/a ),
363n/a ),
364n/a dict(
365n/a # Note that GNU readline is GPL'd software
366n/a name="GNU Readline 6.1.2",
367n/a url="http://ftp.gnu.org/pub/gnu/readline/readline-6.1.tar.gz" ,
368n/a checksum='fc2f7e714fe792db1ce6ddc4c9fb4ef3',
369n/a patchlevel='0',
370n/a patches=[
371n/a # The readline maintainers don't do actual micro releases, but
372n/a # just ship a set of patches.
373n/a ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-001',
374n/a 'c642f2e84d820884b0bf9fd176bc6c3f'),
375n/a ('http://ftp.gnu.org/pub/gnu/readline/readline-6.1-patches/readline61-002',
376n/a '1a76781a1ea734e831588285db7ec9b1'),
377n/a ]
378n/a ),
379n/a ])
380n/a
381n/a if not PYTHON_3:
382n/a result.extend([
383n/a dict(
384n/a name="Sleepycat DB 4.7.25",
385n/a url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
386n/a checksum='ec2b87e833779681a0c3a814aa71359e',
387n/a buildDir="build_unix",
388n/a configure="../dist/configure",
389n/a configure_pre=[
390n/a '--includedir=/usr/local/include/db4',
391n/a ]
392n/a ),
393n/a ])
394n/a
395n/a return result
396n/a
397n/a
398n/a# Instructions for building packages inside the .mpkg.
399n/adef pkg_recipes():
400n/a unselected_for_python3 = ('selected', 'unselected')[PYTHON_3]
401n/a result = [
402n/a dict(
403n/a name="PythonFramework",
404n/a long_name="Python Framework",
405n/a source="/Library/Frameworks/Python.framework",
406n/a readme="""\
407n/a This package installs Python.framework, that is the python
408n/a interpreter and the standard library. This also includes Python
409n/a wrappers for lots of Mac OS X API's.
410n/a """,
411n/a postflight="scripts/postflight.framework",
412n/a selected='selected',
413n/a ),
414n/a dict(
415n/a name="PythonApplications",
416n/a long_name="GUI Applications",
417n/a source="/Applications/Python %(VER)s",
418n/a readme="""\
419n/a This package installs IDLE (an interactive Python IDE),
420n/a Python Launcher and Build Applet (create application bundles
421n/a from python scripts).
422n/a
423n/a It also installs a number of examples and demos.
424n/a """,
425n/a required=False,
426n/a selected='selected',
427n/a ),
428n/a dict(
429n/a name="PythonUnixTools",
430n/a long_name="UNIX command-line tools",
431n/a source="/usr/local/bin",
432n/a readme="""\
433n/a This package installs the unix tools in /usr/local/bin for
434n/a compatibility with older releases of Python. This package
435n/a is not necessary to use Python.
436n/a """,
437n/a required=False,
438n/a selected='selected',
439n/a ),
440n/a dict(
441n/a name="PythonDocumentation",
442n/a long_name="Python Documentation",
443n/a topdir="/Library/Frameworks/Python.framework/Versions/%(VER)s/Resources/English.lproj/Documentation",
444n/a source="/pydocs",
445n/a readme="""\
446n/a This package installs the python documentation at a location
447n/a that is useable for pydoc and IDLE.
448n/a """,
449n/a postflight="scripts/postflight.documentation",
450n/a required=False,
451n/a selected='selected',
452n/a ),
453n/a dict(
454n/a name="PythonProfileChanges",
455n/a long_name="Shell profile updater",
456n/a readme="""\
457n/a This packages updates your shell profile to make sure that
458n/a the Python tools are found by your shell in preference of
459n/a the system provided Python tools.
460n/a
461n/a If you don't install this package you'll have to add
462n/a "/Library/Frameworks/Python.framework/Versions/%(VER)s/bin"
463n/a to your PATH by hand.
464n/a """,
465n/a postflight="scripts/postflight.patch-profile",
466n/a topdir="/Library/Frameworks/Python.framework",
467n/a source="/empty-dir",
468n/a required=False,
469n/a selected='selected',
470n/a ),
471n/a dict(
472n/a name="PythonInstallPip",
473n/a long_name="Install or upgrade pip",
474n/a readme="""\
475n/a This package installs (or upgrades from an earlier version)
476n/a pip, a tool for installing and managing Python packages.
477n/a """,
478n/a postflight="scripts/postflight.ensurepip",
479n/a topdir="/Library/Frameworks/Python.framework",
480n/a source="/empty-dir",
481n/a required=False,
482n/a selected='selected',
483n/a ),
484n/a ]
485n/a
486n/a if getDeptargetTuple() < (10, 4) and not PYTHON_3:
487n/a result.append(
488n/a dict(
489n/a name="PythonSystemFixes",
490n/a long_name="Fix system Python",
491n/a readme="""\
492n/a This package updates the system python installation on
493n/a Mac OS X 10.3 to ensure that you can build new python extensions
494n/a using that copy of python after installing this version.
495n/a """,
496n/a postflight="../Tools/fixapplepython23.py",
497n/a topdir="/Library/Frameworks/Python.framework",
498n/a source="/empty-dir",
499n/a required=False,
500n/a selected=unselected_for_python3,
501n/a )
502n/a )
503n/a
504n/a return result
505n/a
506n/adef fatal(msg):
507n/a """
508n/a A fatal error, bail out.
509n/a """
510n/a sys.stderr.write('FATAL: ')
511n/a sys.stderr.write(msg)
512n/a sys.stderr.write('\n')
513n/a sys.exit(1)
514n/a
515n/adef fileContents(fn):
516n/a """
517n/a Return the contents of the named file
518n/a """
519n/a return open(fn, 'r').read()
520n/a
521n/adef runCommand(commandline):
522n/a """
523n/a Run a command and raise RuntimeError if it fails. Output is suppressed
524n/a unless the command fails.
525n/a """
526n/a fd = os.popen(commandline, 'r')
527n/a data = fd.read()
528n/a xit = fd.close()
529n/a if xit is not None:
530n/a sys.stdout.write(data)
531n/a raise RuntimeError("command failed: %s"%(commandline,))
532n/a
533n/a if VERBOSE:
534n/a sys.stdout.write(data); sys.stdout.flush()
535n/a
536n/adef captureCommand(commandline):
537n/a fd = os.popen(commandline, 'r')
538n/a data = fd.read()
539n/a xit = fd.close()
540n/a if xit is not None:
541n/a sys.stdout.write(data)
542n/a raise RuntimeError("command failed: %s"%(commandline,))
543n/a
544n/a return data
545n/a
546n/adef getTclTkVersion(configfile, versionline):
547n/a """
548n/a search Tcl or Tk configuration file for version line
549n/a """
550n/a try:
551n/a f = open(configfile, "r")
552n/a except OSError:
553n/a fatal("Framework configuration file not found: %s" % configfile)
554n/a
555n/a for l in f:
556n/a if l.startswith(versionline):
557n/a f.close()
558n/a return l
559n/a
560n/a fatal("Version variable %s not found in framework configuration file: %s"
561n/a % (versionline, configfile))
562n/a
563n/adef checkEnvironment():
564n/a """
565n/a Check that we're running on a supported system.
566n/a """
567n/a
568n/a if sys.version_info[0:2] < (2, 4):
569n/a fatal("This script must be run with Python 2.4 or later")
570n/a
571n/a if platform.system() != 'Darwin':
572n/a fatal("This script should be run on a Mac OS X 10.4 (or later) system")
573n/a
574n/a if int(platform.release().split('.')[0]) < 8:
575n/a fatal("This script should be run on a Mac OS X 10.4 (or later) system")
576n/a
577n/a if not os.path.exists(SDKPATH):
578n/a fatal("Please install the latest version of Xcode and the %s SDK"%(
579n/a os.path.basename(SDKPATH[:-4])))
580n/a
581n/a # Because we only support dynamic load of only one major/minor version of
582n/a # Tcl/Tk, ensure:
583n/a # 1. there are no user-installed frameworks of Tcl/Tk with version
584n/a # higher than the Apple-supplied system version in
585n/a # SDKROOT/System/Library/Frameworks
586n/a # 2. there is a user-installed framework (usually ActiveTcl) in (or linked
587n/a # in) SDKROOT/Library/Frameworks with the same version as the system
588n/a # version. This allows users to choose to install a newer patch level.
589n/a
590n/a frameworks = {}
591n/a for framework in ['Tcl', 'Tk']:
592n/a fwpth = 'Library/Frameworks/%s.framework/Versions/Current' % framework
593n/a sysfw = os.path.join(SDKPATH, 'System', fwpth)
594n/a libfw = os.path.join(SDKPATH, fwpth)
595n/a usrfw = os.path.join(os.getenv('HOME'), fwpth)
596n/a frameworks[framework] = os.readlink(sysfw)
597n/a if not os.path.exists(libfw):
598n/a fatal("Please install a link to a current %s %s as %s so "
599n/a "the user can override the system framework."
600n/a % (framework, frameworks[framework], libfw))
601n/a if os.readlink(libfw) != os.readlink(sysfw):
602n/a fatal("Version of %s must match %s" % (libfw, sysfw) )
603n/a if os.path.exists(usrfw):
604n/a fatal("Please rename %s to avoid possible dynamic load issues."
605n/a % usrfw)
606n/a
607n/a if frameworks['Tcl'] != frameworks['Tk']:
608n/a fatal("The Tcl and Tk frameworks are not the same version.")
609n/a
610n/a # add files to check after build
611n/a EXPECTED_SHARED_LIBS['_tkinter.so'] = [
612n/a "/Library/Frameworks/Tcl.framework/Versions/%s/Tcl"
613n/a % frameworks['Tcl'],
614n/a "/Library/Frameworks/Tk.framework/Versions/%s/Tk"
615n/a % frameworks['Tk'],
616n/a ]
617n/a
618n/a # Remove inherited environment variables which might influence build
619n/a environ_var_prefixes = ['CPATH', 'C_INCLUDE_', 'DYLD_', 'LANG', 'LC_',
620n/a 'LD_', 'LIBRARY_', 'PATH', 'PYTHON']
621n/a for ev in list(os.environ):
622n/a for prefix in environ_var_prefixes:
623n/a if ev.startswith(prefix) :
624n/a print("INFO: deleting environment variable %s=%s" % (
625n/a ev, os.environ[ev]))
626n/a del os.environ[ev]
627n/a
628n/a base_path = '/bin:/sbin:/usr/bin:/usr/sbin'
629n/a if 'SDK_TOOLS_BIN' in os.environ:
630n/a base_path = os.environ['SDK_TOOLS_BIN'] + ':' + base_path
631n/a # Xcode 2.5 on OS X 10.4 does not include SetFile in its usr/bin;
632n/a # add its fixed location here if it exists
633n/a OLD_DEVELOPER_TOOLS = '/Developer/Tools'
634n/a if os.path.isdir(OLD_DEVELOPER_TOOLS):
635n/a base_path = base_path + ':' + OLD_DEVELOPER_TOOLS
636n/a os.environ['PATH'] = base_path
637n/a print("Setting default PATH: %s"%(os.environ['PATH']))
638n/a # Ensure ws have access to hg and to sphinx-build.
639n/a # You may have to create links in /usr/bin for them.
640n/a runCommand('hg --version')
641n/a runCommand('sphinx-build --version')
642n/a
643n/adef parseOptions(args=None):
644n/a """
645n/a Parse arguments and update global settings.
646n/a """
647n/a global WORKDIR, DEPSRC, SDKPATH, SRCDIR, DEPTARGET
648n/a global UNIVERSALOPTS, UNIVERSALARCHS, ARCHLIST, CC, CXX
649n/a global FW_VERSION_PREFIX
650n/a global FW_SSL_DIRECTORY
651n/a
652n/a if args is None:
653n/a args = sys.argv[1:]
654n/a
655n/a try:
656n/a options, args = getopt.getopt(args, '?hb',
657n/a [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=',
658n/a 'dep-target=', 'universal-archs=', 'help' ])
659n/a except getopt.GetoptError:
660n/a print(sys.exc_info()[1])
661n/a sys.exit(1)
662n/a
663n/a if args:
664n/a print("Additional arguments")
665n/a sys.exit(1)
666n/a
667n/a deptarget = None
668n/a for k, v in options:
669n/a if k in ('-h', '-?', '--help'):
670n/a print(USAGE)
671n/a sys.exit(0)
672n/a
673n/a elif k in ('-d', '--build-dir'):
674n/a WORKDIR=v
675n/a
676n/a elif k in ('--third-party',):
677n/a DEPSRC=v
678n/a
679n/a elif k in ('--sdk-path',):
680n/a SDKPATH=v
681n/a
682n/a elif k in ('--src-dir',):
683n/a SRCDIR=v
684n/a
685n/a elif k in ('--dep-target', ):
686n/a DEPTARGET=v
687n/a deptarget=v
688n/a
689n/a elif k in ('--universal-archs', ):
690n/a if v in UNIVERSALOPTS:
691n/a UNIVERSALARCHS = v
692n/a ARCHLIST = universal_opts_map[UNIVERSALARCHS]
693n/a if deptarget is None:
694n/a # Select alternate default deployment
695n/a # target
696n/a DEPTARGET = default_target_map.get(v, '10.3')
697n/a else:
698n/a raise NotImplementedError(v)
699n/a
700n/a else:
701n/a raise NotImplementedError(k)
702n/a
703n/a SRCDIR=os.path.abspath(SRCDIR)
704n/a WORKDIR=os.path.abspath(WORKDIR)
705n/a SDKPATH=os.path.abspath(SDKPATH)
706n/a DEPSRC=os.path.abspath(DEPSRC)
707n/a
708n/a CC, CXX = getTargetCompilers()
709n/a
710n/a FW_VERSION_PREFIX = FW_PREFIX[:] + ["Versions", getVersion()]
711n/a FW_SSL_DIRECTORY = FW_VERSION_PREFIX[:] + ["etc", "openssl"]
712n/a
713n/a print("-- Settings:")
714n/a print(" * Source directory: %s" % SRCDIR)
715n/a print(" * Build directory: %s" % WORKDIR)
716n/a print(" * SDK location: %s" % SDKPATH)
717n/a print(" * Third-party source: %s" % DEPSRC)
718n/a print(" * Deployment target: %s" % DEPTARGET)
719n/a print(" * Universal archs: %s" % str(ARCHLIST))
720n/a print(" * C compiler: %s" % CC)
721n/a print(" * C++ compiler: %s" % CXX)
722n/a print("")
723n/a print(" -- Building a Python %s framework at patch level %s"
724n/a % (getVersion(), getFullVersion()))
725n/a print("")
726n/a
727n/adef extractArchive(builddir, archiveName):
728n/a """
729n/a Extract a source archive into 'builddir'. Returns the path of the
730n/a extracted archive.
731n/a
732n/a XXX: This function assumes that archives contain a toplevel directory
733n/a that is has the same name as the basename of the archive. This is
734n/a safe enough for almost anything we use. Unfortunately, it does not
735n/a work for current Tcl and Tk source releases where the basename of
736n/a the archive ends with "-src" but the uncompressed directory does not.
737n/a For now, just special case Tcl and Tk tar.gz downloads.
738n/a """
739n/a curdir = os.getcwd()
740n/a try:
741n/a os.chdir(builddir)
742n/a if archiveName.endswith('.tar.gz'):
743n/a retval = os.path.basename(archiveName[:-7])
744n/a if ((retval.startswith('tcl') or retval.startswith('tk'))
745n/a and retval.endswith('-src')):
746n/a retval = retval[:-4]
747n/a if os.path.exists(retval):
748n/a shutil.rmtree(retval)
749n/a fp = os.popen("tar zxf %s 2>&1"%(shellQuote(archiveName),), 'r')
750n/a
751n/a elif archiveName.endswith('.tar.bz2'):
752n/a retval = os.path.basename(archiveName[:-8])
753n/a if os.path.exists(retval):
754n/a shutil.rmtree(retval)
755n/a fp = os.popen("tar jxf %s 2>&1"%(shellQuote(archiveName),), 'r')
756n/a
757n/a elif archiveName.endswith('.tar'):
758n/a retval = os.path.basename(archiveName[:-4])
759n/a if os.path.exists(retval):
760n/a shutil.rmtree(retval)
761n/a fp = os.popen("tar xf %s 2>&1"%(shellQuote(archiveName),), 'r')
762n/a
763n/a elif archiveName.endswith('.zip'):
764n/a retval = os.path.basename(archiveName[:-4])
765n/a if os.path.exists(retval):
766n/a shutil.rmtree(retval)
767n/a fp = os.popen("unzip %s 2>&1"%(shellQuote(archiveName),), 'r')
768n/a
769n/a data = fp.read()
770n/a xit = fp.close()
771n/a if xit is not None:
772n/a sys.stdout.write(data)
773n/a raise RuntimeError("Cannot extract %s"%(archiveName,))
774n/a
775n/a return os.path.join(builddir, retval)
776n/a
777n/a finally:
778n/a os.chdir(curdir)
779n/a
780n/adef downloadURL(url, fname):
781n/a """
782n/a Download the contents of the url into the file.
783n/a """
784n/a fpIn = urllib_request.urlopen(url)
785n/a fpOut = open(fname, 'wb')
786n/a block = fpIn.read(10240)
787n/a try:
788n/a while block:
789n/a fpOut.write(block)
790n/a block = fpIn.read(10240)
791n/a fpIn.close()
792n/a fpOut.close()
793n/a except:
794n/a try:
795n/a os.unlink(fname)
796n/a except OSError:
797n/a pass
798n/a
799n/adef verifyThirdPartyFile(url, checksum, fname):
800n/a """
801n/a Download file from url to filename fname if it does not already exist.
802n/a Abort if file contents does not match supplied md5 checksum.
803n/a """
804n/a name = os.path.basename(fname)
805n/a if os.path.exists(fname):
806n/a print("Using local copy of %s"%(name,))
807n/a else:
808n/a print("Did not find local copy of %s"%(name,))
809n/a print("Downloading %s"%(name,))
810n/a downloadURL(url, fname)
811n/a print("Archive for %s stored as %s"%(name, fname))
812n/a if os.system(
813n/a 'MD5=$(openssl md5 %s) ; test "${MD5##*= }" = "%s"'
814n/a % (shellQuote(fname), checksum) ):
815n/a fatal('MD5 checksum mismatch for file %s' % fname)
816n/a
817n/adef build_universal_openssl(basedir, archList):
818n/a """
819n/a Special case build recipe for universal build of openssl.
820n/a
821n/a The upstream OpenSSL build system does not directly support
822n/a OS X universal builds. We need to build each architecture
823n/a separately then lipo them together into fat libraries.
824n/a """
825n/a
826n/a # OpenSSL fails to build with Xcode 2.5 (on OS X 10.4).
827n/a # If we are building on a 10.4.x or earlier system,
828n/a # unilaterally disable assembly code building to avoid the problem.
829n/a no_asm = int(platform.release().split(".")[0]) < 9
830n/a
831n/a def build_openssl_arch(archbase, arch):
832n/a "Build one architecture of openssl"
833n/a arch_opts = {
834n/a "i386": ["darwin-i386-cc"],
835n/a "x86_64": ["darwin64-x86_64-cc", "enable-ec_nistp_64_gcc_128"],
836n/a "ppc": ["darwin-ppc-cc"],
837n/a "ppc64": ["darwin64-ppc-cc"],
838n/a }
839n/a configure_opts = [
840n/a "no-krb5",
841n/a "no-idea",
842n/a "no-mdc2",
843n/a "no-rc5",
844n/a "no-zlib",
845n/a "enable-tlsext",
846n/a "no-ssl2",
847n/a "no-ssl3",
848n/a "no-ssl3-method",
849n/a # "enable-unit-test",
850n/a "shared",
851n/a "--install_prefix=%s"%shellQuote(archbase),
852n/a "--prefix=%s"%os.path.join("/", *FW_VERSION_PREFIX),
853n/a "--openssldir=%s"%os.path.join("/", *FW_SSL_DIRECTORY),
854n/a ]
855n/a if no_asm:
856n/a configure_opts.append("no-asm")
857n/a runCommand(" ".join(["perl", "Configure"]
858n/a + arch_opts[arch] + configure_opts))
859n/a runCommand("make depend OSX_SDK=%s" % SDKPATH)
860n/a runCommand("make all OSX_SDK=%s" % SDKPATH)
861n/a runCommand("make install_sw OSX_SDK=%s" % SDKPATH)
862n/a # runCommand("make test")
863n/a return
864n/a
865n/a srcdir = os.getcwd()
866n/a universalbase = os.path.join(srcdir, "..",
867n/a os.path.basename(srcdir) + "-universal")
868n/a os.mkdir(universalbase)
869n/a archbasefws = []
870n/a for arch in archList:
871n/a # fresh copy of the source tree
872n/a archsrc = os.path.join(universalbase, arch, "src")
873n/a shutil.copytree(srcdir, archsrc, symlinks=True)
874n/a # install base for this arch
875n/a archbase = os.path.join(universalbase, arch, "root")
876n/a os.mkdir(archbase)
877n/a # Python framework base within install_prefix:
878n/a # the build will install into this framework..
879n/a # This is to ensure that the resulting shared libs have
880n/a # the desired real install paths built into them.
881n/a archbasefw = os.path.join(archbase, *FW_VERSION_PREFIX)
882n/a
883n/a # build one architecture
884n/a os.chdir(archsrc)
885n/a build_openssl_arch(archbase, arch)
886n/a os.chdir(srcdir)
887n/a archbasefws.append(archbasefw)
888n/a
889n/a # copy arch-independent files from last build into the basedir framework
890n/a basefw = os.path.join(basedir, *FW_VERSION_PREFIX)
891n/a shutil.copytree(
892n/a os.path.join(archbasefw, "include", "openssl"),
893n/a os.path.join(basefw, "include", "openssl")
894n/a )
895n/a
896n/a shlib_version_number = grepValue(os.path.join(archsrc, "Makefile"),
897n/a "SHLIB_VERSION_NUMBER")
898n/a # e.g. -> "1.0.0"
899n/a libcrypto = "libcrypto.dylib"
900n/a libcrypto_versioned = libcrypto.replace(".", "."+shlib_version_number+".")
901n/a # e.g. -> "libcrypto.1.0.0.dylib"
902n/a libssl = "libssl.dylib"
903n/a libssl_versioned = libssl.replace(".", "."+shlib_version_number+".")
904n/a # e.g. -> "libssl.1.0.0.dylib"
905n/a
906n/a try:
907n/a os.mkdir(os.path.join(basefw, "lib"))
908n/a except OSError:
909n/a pass
910n/a
911n/a # merge the individual arch-dependent shared libs into a fat shared lib
912n/a archbasefws.insert(0, basefw)
913n/a for (lib_unversioned, lib_versioned) in [
914n/a (libcrypto, libcrypto_versioned),
915n/a (libssl, libssl_versioned)
916n/a ]:
917n/a runCommand("lipo -create -output " +
918n/a " ".join(shellQuote(
919n/a os.path.join(fw, "lib", lib_versioned))
920n/a for fw in archbasefws))
921n/a # and create an unversioned symlink of it
922n/a os.symlink(lib_versioned, os.path.join(basefw, "lib", lib_unversioned))
923n/a
924n/a # Create links in the temp include and lib dirs that will be injected
925n/a # into the Python build so that setup.py can find them while building
926n/a # and the versioned links so that the setup.py post-build import test
927n/a # does not fail.
928n/a relative_path = os.path.join("..", "..", "..", *FW_VERSION_PREFIX)
929n/a for fn in [
930n/a ["include", "openssl"],
931n/a ["lib", libcrypto],
932n/a ["lib", libssl],
933n/a ["lib", libcrypto_versioned],
934n/a ["lib", libssl_versioned],
935n/a ]:
936n/a os.symlink(
937n/a os.path.join(relative_path, *fn),
938n/a os.path.join(basedir, "usr", "local", *fn)
939n/a )
940n/a
941n/a return
942n/a
943n/adef buildRecipe(recipe, basedir, archList):
944n/a """
945n/a Build software using a recipe. This function does the
946n/a 'configure;make;make install' dance for C software, with a possibility
947n/a to customize this process, basically a poor-mans DarwinPorts.
948n/a """
949n/a curdir = os.getcwd()
950n/a
951n/a name = recipe['name']
952n/a THIRD_PARTY_LIBS.append(name)
953n/a url = recipe['url']
954n/a configure = recipe.get('configure', './configure')
955n/a buildrecipe = recipe.get('buildrecipe', None)
956n/a install = recipe.get('install', 'make && make install DESTDIR=%s'%(
957n/a shellQuote(basedir)))
958n/a
959n/a archiveName = os.path.split(url)[-1]
960n/a sourceArchive = os.path.join(DEPSRC, archiveName)
961n/a
962n/a if not os.path.exists(DEPSRC):
963n/a os.mkdir(DEPSRC)
964n/a
965n/a verifyThirdPartyFile(url, recipe['checksum'], sourceArchive)
966n/a print("Extracting archive for %s"%(name,))
967n/a buildDir=os.path.join(WORKDIR, '_bld')
968n/a if not os.path.exists(buildDir):
969n/a os.mkdir(buildDir)
970n/a
971n/a workDir = extractArchive(buildDir, sourceArchive)
972n/a os.chdir(workDir)
973n/a
974n/a for patch in recipe.get('patches', ()):
975n/a if isinstance(patch, tuple):
976n/a url, checksum = patch
977n/a fn = os.path.join(DEPSRC, os.path.basename(url))
978n/a verifyThirdPartyFile(url, checksum, fn)
979n/a else:
980n/a # patch is a file in the source directory
981n/a fn = os.path.join(curdir, patch)
982n/a runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
983n/a shellQuote(fn),))
984n/a
985n/a for patchscript in recipe.get('patchscripts', ()):
986n/a if isinstance(patchscript, tuple):
987n/a url, checksum = patchscript
988n/a fn = os.path.join(DEPSRC, os.path.basename(url))
989n/a verifyThirdPartyFile(url, checksum, fn)
990n/a else:
991n/a # patch is a file in the source directory
992n/a fn = os.path.join(curdir, patchscript)
993n/a if fn.endswith('.bz2'):
994n/a runCommand('bunzip2 -fk %s' % shellQuote(fn))
995n/a fn = fn[:-4]
996n/a runCommand('sh %s' % shellQuote(fn))
997n/a os.unlink(fn)
998n/a
999n/a if 'buildDir' in recipe:
1000n/a os.chdir(recipe['buildDir'])
1001n/a
1002n/a if configure is not None:
1003n/a configure_args = [
1004n/a "--prefix=/usr/local",
1005n/a "--enable-static",
1006n/a "--disable-shared",
1007n/a #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
1008n/a ]
1009n/a
1010n/a if 'configure_pre' in recipe:
1011n/a args = list(recipe['configure_pre'])
1012n/a if '--disable-static' in args:
1013n/a configure_args.remove('--enable-static')
1014n/a if '--enable-shared' in args:
1015n/a configure_args.remove('--disable-shared')
1016n/a configure_args.extend(args)
1017n/a
1018n/a if recipe.get('useLDFlags', 1):
1019n/a configure_args.extend([
1020n/a "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s "
1021n/a "-I%s/usr/local/include"%(
1022n/a recipe.get('extra_cflags', ''),
1023n/a DEPTARGET,
1024n/a ' -arch '.join(archList),
1025n/a shellQuote(SDKPATH)[1:-1],
1026n/a shellQuote(basedir)[1:-1],),
1027n/a "LDFLAGS=-mmacosx-version-min=%s -isysroot %s -L%s/usr/local/lib -arch %s"%(
1028n/a DEPTARGET,
1029n/a shellQuote(SDKPATH)[1:-1],
1030n/a shellQuote(basedir)[1:-1],
1031n/a ' -arch '.join(archList)),
1032n/a ])
1033n/a else:
1034n/a configure_args.extend([
1035n/a "CFLAGS=%s-mmacosx-version-min=%s -arch %s -isysroot %s "
1036n/a "-I%s/usr/local/include"%(
1037n/a recipe.get('extra_cflags', ''),
1038n/a DEPTARGET,
1039n/a ' -arch '.join(archList),
1040n/a shellQuote(SDKPATH)[1:-1],
1041n/a shellQuote(basedir)[1:-1],),
1042n/a ])
1043n/a
1044n/a if 'configure_post' in recipe:
1045n/a configure_args = configure_args + list(recipe['configure_post'])
1046n/a
1047n/a configure_args.insert(0, configure)
1048n/a configure_args = [ shellQuote(a) for a in configure_args ]
1049n/a
1050n/a print("Running configure for %s"%(name,))
1051n/a runCommand(' '.join(configure_args) + ' 2>&1')
1052n/a
1053n/a if buildrecipe is not None:
1054n/a # call special-case build recipe, e.g. for openssl
1055n/a buildrecipe(basedir, archList)
1056n/a
1057n/a if install is not None:
1058n/a print("Running install for %s"%(name,))
1059n/a runCommand('{ ' + install + ' ;} 2>&1')
1060n/a
1061n/a print("Done %s"%(name,))
1062n/a print("")
1063n/a
1064n/a os.chdir(curdir)
1065n/a
1066n/adef buildLibraries():
1067n/a """
1068n/a Build our dependencies into $WORKDIR/libraries/usr/local
1069n/a """
1070n/a print("")
1071n/a print("Building required libraries")
1072n/a print("")
1073n/a universal = os.path.join(WORKDIR, 'libraries')
1074n/a os.mkdir(universal)
1075n/a os.makedirs(os.path.join(universal, 'usr', 'local', 'lib'))
1076n/a os.makedirs(os.path.join(universal, 'usr', 'local', 'include'))
1077n/a
1078n/a for recipe in library_recipes():
1079n/a buildRecipe(recipe, universal, ARCHLIST)
1080n/a
1081n/a
1082n/a
1083n/adef buildPythonDocs():
1084n/a # This stores the documentation as Resources/English.lproj/Documentation
1085n/a # inside the framwork. pydoc and IDLE will pick it up there.
1086n/a print("Install python documentation")
1087n/a rootDir = os.path.join(WORKDIR, '_root')
1088n/a buildDir = os.path.join('../../Doc')
1089n/a docdir = os.path.join(rootDir, 'pydocs')
1090n/a curDir = os.getcwd()
1091n/a os.chdir(buildDir)
1092n/a # The Doc build changed for 3.4 (technically, for 3.4.1) and for 2.7.9
1093n/a runCommand('make clean')
1094n/a # Assume sphinx-build is on our PATH, checked in checkEnvironment
1095n/a runCommand('make html')
1096n/a os.chdir(curDir)
1097n/a if not os.path.exists(docdir):
1098n/a os.mkdir(docdir)
1099n/a os.rename(os.path.join(buildDir, 'build', 'html'), docdir)
1100n/a
1101n/a
1102n/adef buildPython():
1103n/a print("Building a universal python for %s architectures" % UNIVERSALARCHS)
1104n/a
1105n/a buildDir = os.path.join(WORKDIR, '_bld', 'python')
1106n/a rootDir = os.path.join(WORKDIR, '_root')
1107n/a
1108n/a if os.path.exists(buildDir):
1109n/a shutil.rmtree(buildDir)
1110n/a if os.path.exists(rootDir):
1111n/a shutil.rmtree(rootDir)
1112n/a os.makedirs(buildDir)
1113n/a os.makedirs(rootDir)
1114n/a os.makedirs(os.path.join(rootDir, 'empty-dir'))
1115n/a curdir = os.getcwd()
1116n/a os.chdir(buildDir)
1117n/a
1118n/a # Not sure if this is still needed, the original build script
1119n/a # claims that parts of the install assume python.exe exists.
1120n/a os.symlink('python', os.path.join(buildDir, 'python.exe'))
1121n/a
1122n/a # Extract the version from the configure file, needed to calculate
1123n/a # several paths.
1124n/a version = getVersion()
1125n/a
1126n/a # Since the extra libs are not in their installed framework location
1127n/a # during the build, augment the library path so that the interpreter
1128n/a # will find them during its extension import sanity checks.
1129n/a os.environ['DYLD_LIBRARY_PATH'] = os.path.join(WORKDIR,
1130n/a 'libraries', 'usr', 'local', 'lib')
1131n/a print("Running configure...")
1132n/a runCommand("%s -C --enable-framework --enable-universalsdk=%s "
1133n/a "--with-universal-archs=%s "
1134n/a "%s "
1135n/a "%s "
1136n/a "LDFLAGS='-g -L%s/libraries/usr/local/lib' "
1137n/a "CFLAGS='-g -I%s/libraries/usr/local/include' 2>&1"%(
1138n/a shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH),
1139n/a UNIVERSALARCHS,
1140n/a (' ', '--with-computed-gotos ')[PYTHON_3],
1141n/a (' ', '--without-ensurepip ')[PYTHON_3],
1142n/a shellQuote(WORKDIR)[1:-1],
1143n/a shellQuote(WORKDIR)[1:-1]))
1144n/a
1145n/a print("Running make touch")
1146n/a runCommand("make touch")
1147n/a
1148n/a print("Running make")
1149n/a runCommand("make")
1150n/a
1151n/a print("Running make install")
1152n/a runCommand("make install DESTDIR=%s"%(
1153n/a shellQuote(rootDir)))
1154n/a
1155n/a print("Running make frameworkinstallextras")
1156n/a runCommand("make frameworkinstallextras DESTDIR=%s"%(
1157n/a shellQuote(rootDir)))
1158n/a
1159n/a del os.environ['DYLD_LIBRARY_PATH']
1160n/a print("Copying required shared libraries")
1161n/a if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
1162n/a runCommand("mv %s/* %s"%(
1163n/a shellQuote(os.path.join(
1164n/a WORKDIR, 'libraries', 'Library', 'Frameworks',
1165n/a 'Python.framework', 'Versions', getVersion(),
1166n/a 'lib')),
1167n/a shellQuote(os.path.join(WORKDIR, '_root', 'Library', 'Frameworks',
1168n/a 'Python.framework', 'Versions', getVersion(),
1169n/a 'lib'))))
1170n/a
1171n/a frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
1172n/a frmDirVersioned = os.path.join(frmDir, 'Versions', version)
1173n/a path_to_lib = os.path.join(frmDirVersioned, 'lib', 'python%s'%(version,))
1174n/a # create directory for OpenSSL certificates
1175n/a sslDir = os.path.join(frmDirVersioned, 'etc', 'openssl')
1176n/a os.makedirs(sslDir)
1177n/a
1178n/a print("Fix file modes")
1179n/a gid = grp.getgrnam('admin').gr_gid
1180n/a
1181n/a shared_lib_error = False
1182n/a for dirpath, dirnames, filenames in os.walk(frmDir):
1183n/a for dn in dirnames:
1184n/a os.chmod(os.path.join(dirpath, dn), STAT_0o775)
1185n/a os.chown(os.path.join(dirpath, dn), -1, gid)
1186n/a
1187n/a for fn in filenames:
1188n/a if os.path.islink(fn):
1189n/a continue
1190n/a
1191n/a # "chmod g+w $fn"
1192n/a p = os.path.join(dirpath, fn)
1193n/a st = os.stat(p)
1194n/a os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP)
1195n/a os.chown(p, -1, gid)
1196n/a
1197n/a if fn in EXPECTED_SHARED_LIBS:
1198n/a # check to see that this file was linked with the
1199n/a # expected library path and version
1200n/a data = captureCommand("otool -L %s" % shellQuote(p))
1201n/a for sl in EXPECTED_SHARED_LIBS[fn]:
1202n/a if ("\t%s " % sl) not in data:
1203n/a print("Expected shared lib %s was not linked with %s"
1204n/a % (sl, p))
1205n/a shared_lib_error = True
1206n/a
1207n/a if shared_lib_error:
1208n/a fatal("Unexpected shared library errors.")
1209n/a
1210n/a if PYTHON_3:
1211n/a LDVERSION=None
1212n/a VERSION=None
1213n/a ABIFLAGS=None
1214n/a
1215n/a fp = open(os.path.join(buildDir, 'Makefile'), 'r')
1216n/a for ln in fp:
1217n/a if ln.startswith('VERSION='):
1218n/a VERSION=ln.split()[1]
1219n/a if ln.startswith('ABIFLAGS='):
1220n/a ABIFLAGS=ln.split()[1]
1221n/a if ln.startswith('LDVERSION='):
1222n/a LDVERSION=ln.split()[1]
1223n/a fp.close()
1224n/a
1225n/a LDVERSION = LDVERSION.replace('$(VERSION)', VERSION)
1226n/a LDVERSION = LDVERSION.replace('$(ABIFLAGS)', ABIFLAGS)
1227n/a config_suffix = '-' + LDVERSION
1228n/a if getVersionMajorMinor() >= (3, 6):
1229n/a config_suffix = config_suffix + '-darwin'
1230n/a else:
1231n/a config_suffix = '' # Python 2.x
1232n/a
1233n/a # We added some directories to the search path during the configure
1234n/a # phase. Remove those because those directories won't be there on
1235n/a # the end-users system. Also remove the directories from _sysconfigdata.py
1236n/a # (added in 3.3) if it exists.
1237n/a
1238n/a include_path = '-I%s/libraries/usr/local/include' % (WORKDIR,)
1239n/a lib_path = '-L%s/libraries/usr/local/lib' % (WORKDIR,)
1240n/a
1241n/a # fix Makefile
1242n/a path = os.path.join(path_to_lib, 'config' + config_suffix, 'Makefile')
1243n/a fp = open(path, 'r')
1244n/a data = fp.read()
1245n/a fp.close()
1246n/a
1247n/a for p in (include_path, lib_path):
1248n/a data = data.replace(" " + p, '')
1249n/a data = data.replace(p + " ", '')
1250n/a
1251n/a fp = open(path, 'w')
1252n/a fp.write(data)
1253n/a fp.close()
1254n/a
1255n/a # fix _sysconfigdata
1256n/a #
1257n/a # TODO: make this more robust! test_sysconfig_module of
1258n/a # distutils.tests.test_sysconfig.SysconfigTestCase tests that
1259n/a # the output from get_config_var in both sysconfig and
1260n/a # distutils.sysconfig is exactly the same for both CFLAGS and
1261n/a # LDFLAGS. The fixing up is now complicated by the pretty
1262n/a # printing in _sysconfigdata.py. Also, we are using the
1263n/a # pprint from the Python running the installer build which
1264n/a # may not cosmetically format the same as the pprint in the Python
1265n/a # being built (and which is used to originally generate
1266n/a # _sysconfigdata.py).
1267n/a
1268n/a import pprint
1269n/a if getVersionMajorMinor() >= (3, 6):
1270n/a # XXX this is extra-fragile
1271n/a path = os.path.join(path_to_lib, '_sysconfigdata_m_darwin_darwin.py')
1272n/a else:
1273n/a path = os.path.join(path_to_lib, '_sysconfigdata.py')
1274n/a fp = open(path, 'r')
1275n/a data = fp.read()
1276n/a fp.close()
1277n/a # create build_time_vars dict
1278n/a exec(data)
1279n/a vars = {}
1280n/a for k, v in build_time_vars.items():
1281n/a if type(v) == type(''):
1282n/a for p in (include_path, lib_path):
1283n/a v = v.replace(' ' + p, '')
1284n/a v = v.replace(p + ' ', '')
1285n/a vars[k] = v
1286n/a
1287n/a fp = open(path, 'w')
1288n/a # duplicated from sysconfig._generate_posix_vars()
1289n/a fp.write('# system configuration generated and used by'
1290n/a ' the sysconfig module\n')
1291n/a fp.write('build_time_vars = ')
1292n/a pprint.pprint(vars, stream=fp)
1293n/a fp.close()
1294n/a
1295n/a # Add symlinks in /usr/local/bin, using relative links
1296n/a usr_local_bin = os.path.join(rootDir, 'usr', 'local', 'bin')
1297n/a to_framework = os.path.join('..', '..', '..', 'Library', 'Frameworks',
1298n/a 'Python.framework', 'Versions', version, 'bin')
1299n/a if os.path.exists(usr_local_bin):
1300n/a shutil.rmtree(usr_local_bin)
1301n/a os.makedirs(usr_local_bin)
1302n/a for fn in os.listdir(
1303n/a os.path.join(frmDir, 'Versions', version, 'bin')):
1304n/a os.symlink(os.path.join(to_framework, fn),
1305n/a os.path.join(usr_local_bin, fn))
1306n/a
1307n/a os.chdir(curdir)
1308n/a
1309n/a if PYTHON_3:
1310n/a # Remove the 'Current' link, that way we don't accidentally mess
1311n/a # with an already installed version of python 2
1312n/a os.unlink(os.path.join(rootDir, 'Library', 'Frameworks',
1313n/a 'Python.framework', 'Versions', 'Current'))
1314n/a
1315n/adef patchFile(inPath, outPath):
1316n/a data = fileContents(inPath)
1317n/a data = data.replace('$FULL_VERSION', getFullVersion())
1318n/a data = data.replace('$VERSION', getVersion())
1319n/a data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later')))
1320n/a data = data.replace('$ARCHITECTURES', ", ".join(universal_opts_map[UNIVERSALARCHS]))
1321n/a data = data.replace('$INSTALL_SIZE', installSize())
1322n/a data = data.replace('$THIRD_PARTY_LIBS', "\\\n".join(THIRD_PARTY_LIBS))
1323n/a
1324n/a # This one is not handy as a template variable
1325n/a data = data.replace('$PYTHONFRAMEWORKINSTALLDIR', '/Library/Frameworks/Python.framework')
1326n/a fp = open(outPath, 'w')
1327n/a fp.write(data)
1328n/a fp.close()
1329n/a
1330n/adef patchScript(inPath, outPath):
1331n/a major, minor = getVersionMajorMinor()
1332n/a data = fileContents(inPath)
1333n/a data = data.replace('@PYMAJOR@', str(major))
1334n/a data = data.replace('@PYVER@', getVersion())
1335n/a fp = open(outPath, 'w')
1336n/a fp.write(data)
1337n/a fp.close()
1338n/a os.chmod(outPath, STAT_0o755)
1339n/a
1340n/a
1341n/a
1342n/adef packageFromRecipe(targetDir, recipe):
1343n/a curdir = os.getcwd()
1344n/a try:
1345n/a # The major version (such as 2.5) is included in the package name
1346n/a # because having two version of python installed at the same time is
1347n/a # common.
1348n/a pkgname = '%s-%s'%(recipe['name'], getVersion())
1349n/a srcdir = recipe.get('source')
1350n/a pkgroot = recipe.get('topdir', srcdir)
1351n/a postflight = recipe.get('postflight')
1352n/a readme = textwrap.dedent(recipe['readme'])
1353n/a isRequired = recipe.get('required', True)
1354n/a
1355n/a print("- building package %s"%(pkgname,))
1356n/a
1357n/a # Substitute some variables
1358n/a textvars = dict(
1359n/a VER=getVersion(),
1360n/a FULLVER=getFullVersion(),
1361n/a )
1362n/a readme = readme % textvars
1363n/a
1364n/a if pkgroot is not None:
1365n/a pkgroot = pkgroot % textvars
1366n/a else:
1367n/a pkgroot = '/'
1368n/a
1369n/a if srcdir is not None:
1370n/a srcdir = os.path.join(WORKDIR, '_root', srcdir[1:])
1371n/a srcdir = srcdir % textvars
1372n/a
1373n/a if postflight is not None:
1374n/a postflight = os.path.abspath(postflight)
1375n/a
1376n/a packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents')
1377n/a os.makedirs(packageContents)
1378n/a
1379n/a if srcdir is not None:
1380n/a os.chdir(srcdir)
1381n/a runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),))
1382n/a runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),))
1383n/a runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),))
1384n/a
1385n/a fn = os.path.join(packageContents, 'PkgInfo')
1386n/a fp = open(fn, 'w')
1387n/a fp.write('pmkrpkg1')
1388n/a fp.close()
1389n/a
1390n/a rsrcDir = os.path.join(packageContents, "Resources")
1391n/a os.mkdir(rsrcDir)
1392n/a fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w')
1393n/a fp.write(readme)
1394n/a fp.close()
1395n/a
1396n/a if postflight is not None:
1397n/a patchScript(postflight, os.path.join(rsrcDir, 'postflight'))
1398n/a
1399n/a vers = getFullVersion()
1400n/a major, minor = getVersionMajorMinor()
1401n/a pl = Plist(
1402n/a CFBundleGetInfoString="Python.%s %s"%(pkgname, vers,),
1403n/a CFBundleIdentifier='org.python.Python.%s'%(pkgname,),
1404n/a CFBundleName='Python.%s'%(pkgname,),
1405n/a CFBundleShortVersionString=vers,
1406n/a IFMajorVersion=major,
1407n/a IFMinorVersion=minor,
1408n/a IFPkgFormatVersion=0.10000000149011612,
1409n/a IFPkgFlagAllowBackRev=False,
1410n/a IFPkgFlagAuthorizationAction="RootAuthorization",
1411n/a IFPkgFlagDefaultLocation=pkgroot,
1412n/a IFPkgFlagFollowLinks=True,
1413n/a IFPkgFlagInstallFat=True,
1414n/a IFPkgFlagIsRequired=isRequired,
1415n/a IFPkgFlagOverwritePermissions=False,
1416n/a IFPkgFlagRelocatable=False,
1417n/a IFPkgFlagRestartAction="NoRestart",
1418n/a IFPkgFlagRootVolumeOnly=True,
1419n/a IFPkgFlagUpdateInstalledLangauges=False,
1420n/a )
1421n/a writePlist(pl, os.path.join(packageContents, 'Info.plist'))
1422n/a
1423n/a pl = Plist(
1424n/a IFPkgDescriptionDescription=readme,
1425n/a IFPkgDescriptionTitle=recipe.get('long_name', "Python.%s"%(pkgname,)),
1426n/a IFPkgDescriptionVersion=vers,
1427n/a )
1428n/a writePlist(pl, os.path.join(packageContents, 'Resources', 'Description.plist'))
1429n/a
1430n/a finally:
1431n/a os.chdir(curdir)
1432n/a
1433n/a
1434n/adef makeMpkgPlist(path):
1435n/a
1436n/a vers = getFullVersion()
1437n/a major, minor = getVersionMajorMinor()
1438n/a
1439n/a pl = Plist(
1440n/a CFBundleGetInfoString="Python %s"%(vers,),
1441n/a CFBundleIdentifier='org.python.Python',
1442n/a CFBundleName='Python',
1443n/a CFBundleShortVersionString=vers,
1444n/a IFMajorVersion=major,
1445n/a IFMinorVersion=minor,
1446n/a IFPkgFlagComponentDirectory="Contents/Packages",
1447n/a IFPkgFlagPackageList=[
1448n/a dict(
1449n/a IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()),
1450n/a IFPkgFlagPackageSelection=item.get('selected', 'selected'),
1451n/a )
1452n/a for item in pkg_recipes()
1453n/a ],
1454n/a IFPkgFormatVersion=0.10000000149011612,
1455n/a IFPkgFlagBackgroundScaling="proportional",
1456n/a IFPkgFlagBackgroundAlignment="left",
1457n/a IFPkgFlagAuthorizationAction="RootAuthorization",
1458n/a )
1459n/a
1460n/a writePlist(pl, path)
1461n/a
1462n/a
1463n/adef buildInstaller():
1464n/a
1465n/a # Zap all compiled files
1466n/a for dirpath, _, filenames in os.walk(os.path.join(WORKDIR, '_root')):
1467n/a for fn in filenames:
1468n/a if fn.endswith('.pyc') or fn.endswith('.pyo'):
1469n/a os.unlink(os.path.join(dirpath, fn))
1470n/a
1471n/a outdir = os.path.join(WORKDIR, 'installer')
1472n/a if os.path.exists(outdir):
1473n/a shutil.rmtree(outdir)
1474n/a os.mkdir(outdir)
1475n/a
1476n/a pkgroot = os.path.join(outdir, 'Python.mpkg', 'Contents')
1477n/a pkgcontents = os.path.join(pkgroot, 'Packages')
1478n/a os.makedirs(pkgcontents)
1479n/a for recipe in pkg_recipes():
1480n/a packageFromRecipe(pkgcontents, recipe)
1481n/a
1482n/a rsrcDir = os.path.join(pkgroot, 'Resources')
1483n/a
1484n/a fn = os.path.join(pkgroot, 'PkgInfo')
1485n/a fp = open(fn, 'w')
1486n/a fp.write('pmkrpkg1')
1487n/a fp.close()
1488n/a
1489n/a os.mkdir(rsrcDir)
1490n/a
1491n/a makeMpkgPlist(os.path.join(pkgroot, 'Info.plist'))
1492n/a pl = Plist(
1493n/a IFPkgDescriptionTitle="Python",
1494n/a IFPkgDescriptionVersion=getVersion(),
1495n/a )
1496n/a
1497n/a writePlist(pl, os.path.join(pkgroot, 'Resources', 'Description.plist'))
1498n/a for fn in os.listdir('resources'):
1499n/a if fn == '.svn': continue
1500n/a if fn.endswith('.jpg'):
1501n/a shutil.copy(os.path.join('resources', fn), os.path.join(rsrcDir, fn))
1502n/a else:
1503n/a patchFile(os.path.join('resources', fn), os.path.join(rsrcDir, fn))
1504n/a
1505n/a
1506n/adef installSize(clear=False, _saved=[]):
1507n/a if clear:
1508n/a del _saved[:]
1509n/a if not _saved:
1510n/a data = captureCommand("du -ks %s"%(
1511n/a shellQuote(os.path.join(WORKDIR, '_root'))))
1512n/a _saved.append("%d"%((0.5 + (int(data.split()[0]) / 1024.0)),))
1513n/a return _saved[0]
1514n/a
1515n/a
1516n/adef buildDMG():
1517n/a """
1518n/a Create DMG containing the rootDir.
1519n/a """
1520n/a outdir = os.path.join(WORKDIR, 'diskimage')
1521n/a if os.path.exists(outdir):
1522n/a shutil.rmtree(outdir)
1523n/a
1524n/a imagepath = os.path.join(outdir,
1525n/a 'python-%s-macosx%s'%(getFullVersion(),DEPTARGET))
1526n/a if INCLUDE_TIMESTAMP:
1527n/a imagepath = imagepath + '-%04d-%02d-%02d'%(time.localtime()[:3])
1528n/a imagepath = imagepath + '.dmg'
1529n/a
1530n/a os.mkdir(outdir)
1531n/a volname='Python %s'%(getFullVersion())
1532n/a runCommand("hdiutil create -format UDRW -volname %s -srcfolder %s %s"%(
1533n/a shellQuote(volname),
1534n/a shellQuote(os.path.join(WORKDIR, 'installer')),
1535n/a shellQuote(imagepath + ".tmp.dmg" )))
1536n/a
1537n/a
1538n/a if not os.path.exists(os.path.join(WORKDIR, "mnt")):
1539n/a os.mkdir(os.path.join(WORKDIR, "mnt"))
1540n/a runCommand("hdiutil attach %s -mountroot %s"%(
1541n/a shellQuote(imagepath + ".tmp.dmg"), shellQuote(os.path.join(WORKDIR, "mnt"))))
1542n/a
1543n/a # Custom icon for the DMG, shown when the DMG is mounted.
1544n/a shutil.copy("../Icons/Disk Image.icns",
1545n/a os.path.join(WORKDIR, "mnt", volname, ".VolumeIcon.icns"))
1546n/a runCommand("SetFile -a C %s/"%(
1547n/a shellQuote(os.path.join(WORKDIR, "mnt", volname)),))
1548n/a
1549n/a runCommand("hdiutil detach %s"%(shellQuote(os.path.join(WORKDIR, "mnt", volname))))
1550n/a
1551n/a setIcon(imagepath + ".tmp.dmg", "../Icons/Disk Image.icns")
1552n/a runCommand("hdiutil convert %s -format UDZO -o %s"%(
1553n/a shellQuote(imagepath + ".tmp.dmg"), shellQuote(imagepath)))
1554n/a setIcon(imagepath, "../Icons/Disk Image.icns")
1555n/a
1556n/a os.unlink(imagepath + ".tmp.dmg")
1557n/a
1558n/a return imagepath
1559n/a
1560n/a
1561n/adef setIcon(filePath, icnsPath):
1562n/a """
1563n/a Set the custom icon for the specified file or directory.
1564n/a """
1565n/a
1566n/a dirPath = os.path.normpath(os.path.dirname(__file__))
1567n/a toolPath = os.path.join(dirPath, "seticon.app/Contents/MacOS/seticon")
1568n/a if not os.path.exists(toolPath) or os.stat(toolPath).st_mtime < os.stat(dirPath + '/seticon.m').st_mtime:
1569n/a # NOTE: The tool is created inside an .app bundle, otherwise it won't work due
1570n/a # to connections to the window server.
1571n/a appPath = os.path.join(dirPath, "seticon.app/Contents/MacOS")
1572n/a if not os.path.exists(appPath):
1573n/a os.makedirs(appPath)
1574n/a runCommand("cc -o %s %s/seticon.m -framework Cocoa"%(
1575n/a shellQuote(toolPath), shellQuote(dirPath)))
1576n/a
1577n/a runCommand("%s %s %s"%(shellQuote(os.path.abspath(toolPath)), shellQuote(icnsPath),
1578n/a shellQuote(filePath)))
1579n/a
1580n/adef main():
1581n/a # First parse options and check if we can perform our work
1582n/a parseOptions()
1583n/a checkEnvironment()
1584n/a
1585n/a os.environ['MACOSX_DEPLOYMENT_TARGET'] = DEPTARGET
1586n/a os.environ['CC'] = CC
1587n/a os.environ['CXX'] = CXX
1588n/a
1589n/a if os.path.exists(WORKDIR):
1590n/a shutil.rmtree(WORKDIR)
1591n/a os.mkdir(WORKDIR)
1592n/a
1593n/a os.environ['LC_ALL'] = 'C'
1594n/a
1595n/a # Then build third-party libraries such as sleepycat DB4.
1596n/a buildLibraries()
1597n/a
1598n/a # Now build python itself
1599n/a buildPython()
1600n/a
1601n/a # And then build the documentation
1602n/a # Remove the Deployment Target from the shell
1603n/a # environment, it's no longer needed and
1604n/a # an unexpected build target can cause problems
1605n/a # when Sphinx and its dependencies need to
1606n/a # be (re-)installed.
1607n/a del os.environ['MACOSX_DEPLOYMENT_TARGET']
1608n/a buildPythonDocs()
1609n/a
1610n/a
1611n/a # Prepare the applications folder
1612n/a folder = os.path.join(WORKDIR, "_root", "Applications", "Python %s"%(
1613n/a getVersion(),))
1614n/a fn = os.path.join(folder, "License.rtf")
1615n/a patchFile("resources/License.rtf", fn)
1616n/a fn = os.path.join(folder, "ReadMe.rtf")
1617n/a patchFile("resources/ReadMe.rtf", fn)
1618n/a fn = os.path.join(folder, "Update Shell Profile.command")
1619n/a patchScript("scripts/postflight.patch-profile", fn)
1620n/a fn = os.path.join(folder, "Install Certificates.command")
1621n/a patchScript("resources/install_certificates.command", fn)
1622n/a os.chmod(folder, STAT_0o755)
1623n/a setIcon(folder, "../Icons/Python Folder.icns")
1624n/a
1625n/a # Create the installer
1626n/a buildInstaller()
1627n/a
1628n/a # And copy the readme into the directory containing the installer
1629n/a patchFile('resources/ReadMe.rtf',
1630n/a os.path.join(WORKDIR, 'installer', 'ReadMe.rtf'))
1631n/a
1632n/a # Ditto for the license file.
1633n/a patchFile('resources/License.rtf',
1634n/a os.path.join(WORKDIR, 'installer', 'License.rtf'))
1635n/a
1636n/a fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
1637n/a fp.write("# BUILD INFO\n")
1638n/a fp.write("# Date: %s\n" % time.ctime())
1639n/a fp.write("# By: %s\n" % pwd.getpwuid(os.getuid()).pw_gecos)
1640n/a fp.close()
1641n/a
1642n/a # And copy it to a DMG
1643n/a buildDMG()
1644n/a
1645n/aif __name__ == "__main__":
1646n/a main()