blob: 66d9935de1bf1a5faa3d40e953851fc3924ec0ba [file] [log] [blame]
Ned Deily22726702011-01-15 04:44:12 +00001Building a Python Mac OS X distribution
2=======================================
Thomas Wouters477c8d52006-05-27 19:21:47 +00003
Ned Deilyfc4ead22014-09-19 21:03:45 -07004The ``build-installer.py`` script creates Python distributions, including
Ned Deily22726702011-01-15 04:44:12 +00005certain third-party libraries as necessary. It builds a complete
Thomas Wouters477c8d52006-05-27 19:21:47 +00006framework-based Python out-of-tree, installs it in a funny place with
7$DESTROOT, massages that installation to remove .pyc files and such, creates
8an Installer package from the installation plus other files in ``resources``
9and ``scripts`` and placed that on a ``.dmg`` disk image.
10
Ned Deilyfc4ead22014-09-19 21:03:45 -070011This installers built by this script are legacy bundle installers that have
12been supported from the early days of OS X. In particular, they are supported
13on OS X 10.3.9, the earliest supported release for builds from this script.
14
15Beginning with Python 3.4.2, PSF practice is to build two installer variants
16using the newer flat package format, supported on 10.5+, and signed with the
17builder's Apple developer key, allowing downloaded packages to satisfy Apple's
18default Gatekeeper policy (e.g. starting with 10.8, Apple store downloads and
19Apple developer ID signed apps and installer packages). The process for
20transforming the output build artifacts into signed flat packages is not
21yet integrated into ``build-installer.py``. The steps prior to the flat
22package creation are the same as for 3.4.1 below.
23
24For Python 3.4.0 and 3.4.1, PSF practice was to build two installer variants
Ned Deily5c0b1ca2012-08-24 19:57:33 -070025for each release.
Thomas Wouters477c8d52006-05-27 19:21:47 +000026
Ned Deily22726702011-01-15 04:44:12 +0000271. 32-bit-only, i386 and PPC universal, capable on running on all machines
Ned Deily7e60f512014-04-07 12:10:21 -070028 supported by Mac OS X 10.5 through (at least) 10.9::
Thomas Wouters0e3f5912006-08-11 14:57:12 +000029
Ned Deily7e60f512014-04-07 12:10:21 -070030 /path/to/bootstrap/python2.7 build-installer.py \
Ned Deily5c0b1ca2012-08-24 19:57:33 -070031 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \
32 --universal-archs=32-bit \
33 --dep-target=10.5
34
35 - builds the following third-party libraries
36
37 * NCurses 5.9 (http://bugs.python.org/issue15037)
Ned Deily7e60f512014-04-07 12:10:21 -070038 * SQLite 3.8.3.1
Ned Deily9fa4ced2013-11-22 22:54:02 -080039 * XZ 5.0.5
Ned Deily5c0b1ca2012-08-24 19:57:33 -070040
41 - uses system-supplied versions of third-party libraries
42
43 * readline module links with Apple BSD editline (libedit)
44
Ned Deily7e60f512014-04-07 12:10:21 -070045 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building
Ned Deily5c0b1ca2012-08-24 19:57:33 -070046
47 - recommended build environment:
48
49 * Mac OS X 10.5.8 Intel or PPC
50 * Xcode 3.1.4
51 * ``MacOSX10.5`` SDK
52 * ``MACOSX_DEPLOYMENT_TARGET=10.5``
53 * Apple ``gcc-4.2``
Ned Deily7e60f512014-04-07 12:10:21 -070054 * bootstrap non-framework Python 2.7 for documentation build with
55 Sphinx (as of 3.4.1)
Ned Deily5c0b1ca2012-08-24 19:57:33 -070056
57 - alternate build environments:
58
59 * Mac OS X 10.6.8 with Xcode 3.2.6
60 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
61 * Note Xcode 4.* does not support building for PPC so cannot be used for this build
62
632. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later)::
64
Ned Deily7e60f512014-04-07 12:10:21 -070065 /path/to/bootstrap/python2.7 build-installer.py \
Ned Deily5c0b1ca2012-08-24 19:57:33 -070066 --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \
67 --universal-archs=intel \
68 --dep-target=10.6
69
70 - builds the following third-party libraries
71
72 * NCurses 5.9 (http://bugs.python.org/issue15037)
Ned Deily7e60f512014-04-07 12:10:21 -070073 * SQLite 3.8.3.1
Ned Deily9fa4ced2013-11-22 22:54:02 -080074 * XZ 5.0.5
Ned Deily5c0b1ca2012-08-24 19:57:33 -070075
76 - uses system-supplied versions of third-party libraries
77
78 * readline module links with Apple BSD editline (libedit)
79
Ned Deily7e60f512014-04-07 12:10:21 -070080 - requires ActiveState Tcl/Tk 8.5.15.1 (or later) to be installed for building
Ned Deily981b6932013-09-06 01:18:36 -070081
Ned Deily5c0b1ca2012-08-24 19:57:33 -070082 - recommended build environment:
83
84 * Mac OS X 10.6.8 (or later)
85 * Xcode 3.2.6
86 * ``MacOSX10.6`` SDK
87 * ``MACOSX_DEPLOYMENT_TARGET=10.6``
88 * Apple ``gcc-4.2``
Ned Deily7e60f512014-04-07 12:10:21 -070089 * bootstrap non-framework Python 2.7 for documentation build with
90 Sphinx (as of 3.4.1)
Ned Deily5c0b1ca2012-08-24 19:57:33 -070091
92 - alternate build environments:
93
94 * none. Xcode 4.x currently supplies two C compilers.
95 ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and
96 produce a non-functional Python executable. As it appears to be
97 considered a migration aid by Apple and is not likely to be fixed,
98 its use should be avoided. The other compiler, ``clang``, has been
99 undergoing rapid development. While it appears to have become
Ned Deily7e60f512014-04-07 12:10:21 -0700100 production-ready in the most recent Xcode 5 releases, the versions
101 available on the deprecated Xcode 4.x for 10.6 were early releases
102 and did not receive the level of exposure in production environments
103 that the Xcode 3 gcc-4.2 compiler has had.
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700104
105
106* For Python 2.7.x and 3.2.x, the 32-bit-only installer was configured to
107 support Mac OS X 10.3.9 through (at least) 10.6. Because it is
108 believed that there are few systems still running OS X 10.3 or 10.4
109 and because it has become increasingly difficult to test and
110 support the differences in these earlier systems, as of Python 3.3.0 the PSF
111 32-bit installer no longer supports them. For reference in building such
112 an installer yourself, the details are::
113
114 /usr/bin/python build-installer.py \
Ned Deily22726702011-01-15 04:44:12 +0000115 --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \
116 --universal-archs=32-bit \
117 --dep-target=10.3
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000118
Ned Deily22726702011-01-15 04:44:12 +0000119 - builds the following third-party libraries
120
121 * Bzip2
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700122 * NCurses
Ned Deily22726702011-01-15 04:44:12 +0000123 * GNU Readline (GPL)
124 * SQLite 3
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700125 * XZ
126 * Zlib 1.2.3
Ned Deily22726702011-01-15 04:44:12 +0000127 * Oracle Sleepycat DB 4.8 (Python 2.x only)
128
Ned Deily7e60f512014-04-07 12:10:21 -0700129 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building
Ned Deily22726702011-01-15 04:44:12 +0000130
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700131 - recommended build environment:
Ned Deily22726702011-01-15 04:44:12 +0000132
133 * Mac OS X 10.5.8 PPC or Intel
134 * Xcode 3.1.4 (or later)
135 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors)
136 * ``MACOSX_DEPLOYMENT_TARGET=10.3``
137 * Apple ``gcc-4.0``
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700138 * system Python 2.5 for documentation build with Sphinx
Ned Deily22726702011-01-15 04:44:12 +0000139
140 - alternate build environments:
141
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700142 * Mac OS X 10.6.8 with Xcode 3.2.6
Ned Deily22726702011-01-15 04:44:12 +0000143 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
144
Ned Deily22726702011-01-15 04:44:12 +0000145
146
147General Prerequisites
148---------------------
149
150* No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local
151 libraries or utilities (in ``/usr/local``) as they could
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000152 interfere with the build.
153
Ned Deily22726702011-01-15 04:44:12 +0000154* The documentation for the release is built using Sphinx
Ned Deily7e60f512014-04-07 12:10:21 -0700155 because it is included in the installer. For 2.7.x and 3.x.x up to and
156 including 3.4.0, the ``Doc/Makefile`` uses ``svn`` to download repos of
157 ``Sphinx`` and its dependencies. Beginning with 3.4.1, the ``Doc/Makefile``
158 assumes there is an externally-provided ``sphinx-build`` and requires at
159 least Python 2.6 to run. Because of this, it is no longer possible to
160 build a 3.4.1 or later installer on OS X 10.5 using the Apple-supplied
161 Python 2.5.
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000162
Ned Deily22726702011-01-15 04:44:12 +0000163* It is safest to start each variant build with an empty source directory
164 populated with a fresh copy of the untarred source.
165
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700166* It is recommended that you remove any existing installed version of the
167 Python being built::
168
169 sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n
170
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000171
172The Recipe
173----------
174
Ned Deily22726702011-01-15 04:44:12 +0000175Here are the steps you need to follow to build a Python installer:
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000176
Ned Deily22726702011-01-15 04:44:12 +0000177* Run ``build-installer.py``. Optionally you can pass a number of arguments
178 to specify locations of various files. Please see the top of
Thomas Wouters477c8d52006-05-27 19:21:47 +0000179 ``build-installer.py`` for its usage.
Thomas Wouters477c8d52006-05-27 19:21:47 +0000180
Ned Deily22726702011-01-15 04:44:12 +0000181 Running this script takes some time, it will not only build Python itself
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000182 but also some 3th-party libraries that are needed for extensions.
183
184* When done the script will tell you where the DMG image is (by default
185 somewhere in ``/tmp/_py``).
186
Ned Deily22726702011-01-15 04:44:12 +0000187Building other universal installers
188...................................
Ronald Oussoren1943f862009-03-30 19:39:14 +0000189
190It is also possible to build a 4-way universal installer that runs on
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700191OS X 10.5 Leopard or later::
Ronald Oussoren1943f862009-03-30 19:39:14 +0000192
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700193 /usr/bin/python /build-installer.py \
Ned Deily22726702011-01-15 04:44:12 +0000194 --dep-target=10.5
195 --universal-archs=all
196 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk
Ronald Oussoren1943f862009-03-30 19:39:14 +0000197
Ned Deily22726702011-01-15 04:44:12 +0000198This requires that the deployment target is 10.5, and hence
199also that you are building on at least OS X 10.5. 4-way includes
200``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable
201variants can only be run on G5 machines running 10.5. Note that,
202while OS X 10.6 is only supported on Intel-based machines, it is possible
203to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700204emulation in OS X 10.5 and 10.6. The 4-way installer variant must be
205built with Xcode 3. It is not regularly built or tested.
Ned Deily22726702011-01-15 04:44:12 +0000206
207Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``),
208and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options
209are regularly exercised; use at your own risk.
210
Ronald Oussoren1943f862009-03-30 19:39:14 +0000211
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000212Testing
213-------
214
Ned Deily22726702011-01-15 04:44:12 +0000215Ideally, the resulting binaries should be installed and the test suite run
216on all supported OS X releases and architectures. As a practical matter,
217that is generally not possible. At a minimum, variant 1 should be run on
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700218a PPC G4 system with OS X 10.5 and at least one Intel system running OS X
Ned Deily7e60f512014-04-07 12:10:21 -070021910.9, 10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.9, 10.8,
22010.7, and 10.6 systems in both 32-bit and 64-bit modes.::
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000221
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700222 /usr/local/bin/pythonn.n -m test -w -u all,-largefile
223 /usr/local/bin/pythonn.n-32 -m test -w -u all
Ned Deily22726702011-01-15 04:44:12 +0000224
225Certain tests will be skipped and some cause the interpreter to fail
226which will likely generate ``Python quit unexpectedly`` alert messages
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700227to be generated at several points during a test run. These are normal
228during testing and can be ignored.
229
230It is also recommend to launch IDLE and verify that it is at least
Ned Deily7e60f512014-04-07 12:10:21 -0700231functional. Double-click on the IDLE app icon in ``/Applications/Python n.n``.
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700232It should also be tested from the command line::
233
234 /usr/local/bin/idlen.n
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000235