blob: 268a13623318cfafa8c32e06481b3030d496feb6 [file] [log] [blame]
Ned Deily53c460d2011-01-30 01:43:40 +00001Building a Python Mac OS X distribution
2=======================================
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +00003
Ned Deily53c460d2011-01-30 01:43:40 +00004The ``build-install.py`` script creates Python distributions, including
5certain third-party libraries as necessary. It builds a complete
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +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 Deily78cceec2014-05-17 14:29:22 -070011For Python 2.7.x and 3.x, PSF practice is to build two installer variants
Ned Deilye1c9794952013-01-29 00:07:46 -080012for each release.
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +000013
Ned Deilyfcf701a2014-09-05 15:52:45 -070014Beginning with Python 2.7.9, we plan to drop binary installer support for
Ned Deily78cceec2014-05-17 14:29:22 -070015Mac OS X 10.3.9 and 10.4.x systems. To ease the transition, for Python 2.7.7
Ned Deilyfcf701a2014-09-05 15:52:45 -070016and 2.7.8 there were three installers provided:
Ned Deily78cceec2014-05-17 14:29:22 -070017
181. DEPRECATED - 32-bit-only, i386 and PPC universal, capable on running on all
19 machines supported by Mac OS X 10.3.9 through (at least) 10.9::
Ronald Oussoren5fb9c202006-08-02 06:10:10 +000020
Ned Deilye1c9794952013-01-29 00:07:46 -080021 /usr/bin/python build-installer.py \
Ned Deily53c460d2011-01-30 01:43:40 +000022 --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \
23 --universal-archs=32-bit \
24 --dep-target=10.3
Ronald Oussoren5fb9c202006-08-02 06:10:10 +000025
Ned Deily53c460d2011-01-30 01:43:40 +000026 - builds the following third-party libraries
27
28 * Bzip2
Ned Deily53c460d2011-01-30 01:43:40 +000029 * NCurses
Ned Deilye1c9794952013-01-29 00:07:46 -080030 * GNU Readline (GPL)
31 * SQLite 3.7.13
32 * Zlib 1.2.3
Ned Deily53c460d2011-01-30 01:43:40 +000033 * Oracle Sleepycat DB 4.8 (Python 2.x only)
34
35 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building
36
Ned Deilye1c9794952013-01-29 00:07:46 -080037 - recommended build environment:
Ned Deily53c460d2011-01-30 01:43:40 +000038
39 * Mac OS X 10.5.8 PPC or Intel
Ned Deilye1c9794952013-01-29 00:07:46 -080040 * Xcode 3.1.4
Ned Deily53c460d2011-01-30 01:43:40 +000041 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors)
42 * ``MACOSX_DEPLOYMENT_TARGET=10.3``
43 * Apple ``gcc-4.0``
Ned Deilyfcf701a2014-09-05 15:52:45 -070044 * bootstrap non-framework Python 2.7 for documentation build with
45 Sphinx (as of 2.7.9)
Ned Deily53c460d2011-01-30 01:43:40 +000046
47 - alternate build environments:
48
Ned Deilye1c9794952013-01-29 00:07:46 -080049 * Mac OS X 10.6.8 with Xcode 3.2.6
Ned Deily53c460d2011-01-30 01:43:40 +000050 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
Ned Deilye1c9794952013-01-29 00:07:46 -080051 * Note Xcode 4.* does not support building for PPC so cannot be used for this build
52
Ned Deily78cceec2014-05-17 14:29:22 -0700532. 32-bit-only, i386 and PPC universal, capable on running on all machines
54 supported by Mac OS X 10.5 through (at least) 10.9::
Ned Deily53c460d2011-01-30 01:43:40 +000055
Ned Deily78cceec2014-05-17 14:29:22 -070056 /usr/bin/python build-installer.py \
57 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \
58 --universal-archs=32-bit \
59 --dep-target=10.5
60
61 - builds the following third-party libraries
62
63 * NCurses 5.9
64 * SQLite 3.7.13
65 * Oracle Sleepycat DB 4.8 (Python 2.x only)
66
67 - uses system-supplied versions of third-party libraries
68
69 * readline module links with Apple BSD editline (libedit)
70
71 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building
72
73 - recommended build environment:
74
75 * Mac OS X 10.5.8 Intel or PPC
76 * Xcode 3.1.4
77 * ``MacOSX10.5`` SDK
78 * ``MACOSX_DEPLOYMENT_TARGET=10.5``
79 * Apple ``gcc-4.2``
Ned Deilyfcf701a2014-09-05 15:52:45 -070080 * bootstrap non-framework Python 2.7 for documentation build with
81 Sphinx (as of 2.7.9)
Ned Deily78cceec2014-05-17 14:29:22 -070082
83 - alternate build environments:
84
85 * Mac OS X 10.6.8 with Xcode 3.2.6
86 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
87 * Note Xcode 4.* does not support building for PPC so cannot be used for this build
88
893. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later)::
Ned Deily53c460d2011-01-30 01:43:40 +000090
Ned Deilye1c9794952013-01-29 00:07:46 -080091 /usr/bin/python build-installer.py \
Ned Deily53c460d2011-01-30 01:43:40 +000092 --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \
93 --universal-archs=intel \
94 --dep-target=10.6
95
Ned Deilye1c9794952013-01-29 00:07:46 -080096 - builds the following third-party libraries
97
98 * NCurses 5.9 (http://bugs.python.org/issue15037)
99 * SQLite 3.7.13
Ned Deily78cceec2014-05-17 14:29:22 -0700100 * Oracle Sleepycat DB 4.8 (Python 2.x only)
Ned Deilye1c9794952013-01-29 00:07:46 -0800101
Ned Deily53c460d2011-01-30 01:43:40 +0000102 - uses system-supplied versions of third-party libraries
Ned Deilye1c9794952013-01-29 00:07:46 -0800103
Ned Deily53c460d2011-01-30 01:43:40 +0000104 * readline module links with Apple BSD editline (libedit)
Ned Deily53c460d2011-01-30 01:43:40 +0000105
Ned Deily78cceec2014-05-17 14:29:22 -0700106 - requires ActiveState Tcl/Tk 8.5.15 (or later) to be installed for building
Ned Deily53c460d2011-01-30 01:43:40 +0000107
Ned Deilye1c9794952013-01-29 00:07:46 -0800108 - recommended build environment:
109
110 * Mac OS X 10.6.8 (or later)
111 * Xcode 3.2.6
Ned Deily53c460d2011-01-30 01:43:40 +0000112 * ``MacOSX10.6`` SDK
113 * ``MACOSX_DEPLOYMENT_TARGET=10.6``
114 * Apple ``gcc-4.2``
Ned Deilyfcf701a2014-09-05 15:52:45 -0700115 * bootstrap non-framework Python 2.7 for documentation build with
116 Sphinx (as of 2.7.9)
Ned Deily53c460d2011-01-30 01:43:40 +0000117
118 - alternate build environments:
119
Ned Deilye1c9794952013-01-29 00:07:46 -0800120 * none. Xcode 4.x currently supplies two C compilers.
121 ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and
122 produce a non-functional Python executable. As it appears to be
123 considered a migration aid by Apple and is not likely to be fixed,
124 its use should be avoided. The other compiler, ``clang``, has been
125 undergoing rapid development. While it appears to have become
Ned Deily78cceec2014-05-17 14:29:22 -0700126 production-ready in the most recent Xcode 5 releases, the versions
127 available on the deprecated Xcode 4.x for 10.6 were early releases
128 and did not receive the level of exposure in production environments
129 that the Xcode 3 gcc-4.2 compiler has had.
Ned Deily53c460d2011-01-30 01:43:40 +0000130
131
132General Prerequisites
133---------------------
134
135* No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local
136 libraries or utilities (in ``/usr/local``) as they could
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000137 interfere with the build.
138
Ned Deily53c460d2011-01-30 01:43:40 +0000139* The documentation for the release is built using Sphinx
Ned Deilyfcf701a2014-09-05 15:52:45 -0700140 because it is included in the installer. For 2.7.x up to and including
141 2.7.8, the ``Doc/Makefile`` used ``svn`` to download repos of
142 ``Sphinx`` and its dependencies. Beginning with 2.7.9, the ``Doc/Makefile``
143 assumes there is an externally-provided ``sphinx-build`` and requires at
144 least Python 2.6 to run. Because of this, it is no longer possible to
145 build a 2.7.9 or later installer on OS X 10.5 using the Apple-supplied
146 Python 2.5.
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000147
Ned Deily53c460d2011-01-30 01:43:40 +0000148* It is safest to start each variant build with an empty source directory
149 populated with a fresh copy of the untarred source.
150
Ned Deilye1c9794952013-01-29 00:07:46 -0800151* It is recommended that you remove any existing installed version of the
152 Python being built::
153
154 sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n
155
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000156
157The Recipe
158----------
159
Ned Deily53c460d2011-01-30 01:43:40 +0000160Here are the steps you need to follow to build a Python installer:
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000161
Ned Deily53c460d2011-01-30 01:43:40 +0000162* Run ``build-installer.py``. Optionally you can pass a number of arguments
163 to specify locations of various files. Please see the top of
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +0000164 ``build-installer.py`` for its usage.
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +0000165
Ned Deily53c460d2011-01-30 01:43:40 +0000166 Running this script takes some time, it will not only build Python itself
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000167 but also some 3th-party libraries that are needed for extensions.
168
169* When done the script will tell you where the DMG image is (by default
170 somewhere in ``/tmp/_py``).
171
Ned Deily53c460d2011-01-30 01:43:40 +0000172Building other universal installers
173...................................
Ronald Oussoren508282e2009-03-30 19:34:51 +0000174
175It is also possible to build a 4-way universal installer that runs on
Ned Deilye1c9794952013-01-29 00:07:46 -0800176OS X 10.5 Leopard or later::
Ronald Oussoren508282e2009-03-30 19:34:51 +0000177
Ned Deilye1c9794952013-01-29 00:07:46 -0800178 /usr/bin/python /build-installer.py \
Ned Deily53c460d2011-01-30 01:43:40 +0000179 --dep-target=10.5
180 --universal-archs=all
181 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk
Ronald Oussoren508282e2009-03-30 19:34:51 +0000182
Ned Deily53c460d2011-01-30 01:43:40 +0000183This requires that the deployment target is 10.5, and hence
184also that you are building on at least OS X 10.5. 4-way includes
185``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable
186variants can only be run on G5 machines running 10.5. Note that,
187while OS X 10.6 is only supported on Intel-based machines, it is possible
188to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc
Ned Deilye1c9794952013-01-29 00:07:46 -0800189emulation in OS X 10.5 and 10.6. The 4-way installer variant must be
190built with Xcode 3. It is not regularly built or tested.
Ned Deily53c460d2011-01-30 01:43:40 +0000191
192Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``),
193and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options
194are regularly exercised; use at your own risk.
195
Ronald Oussoren508282e2009-03-30 19:34:51 +0000196
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000197Testing
198-------
199
Ned Deily53c460d2011-01-30 01:43:40 +0000200Ideally, the resulting binaries should be installed and the test suite run
201on all supported OS X releases and architectures. As a practical matter,
202that is generally not possible. At a minimum, variant 1 should be run on
Ned Deilye1c9794952013-01-29 00:07:46 -0800203a PPC G4 system with OS X 10.5 and at least one Intel system running OS X
20410.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6
205systems in both 32-bit and 64-bit modes.::
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000206
Ned Deilye1c9794952013-01-29 00:07:46 -0800207 /usr/local/bin/pythonn.n -m test -w -u all,-largefile
208 /usr/local/bin/pythonn.n-32 -m test -w -u all
Ned Deily53c460d2011-01-30 01:43:40 +0000209
210Certain tests will be skipped and some cause the interpreter to fail
211which will likely generate ``Python quit unexpectedly`` alert messages
Ned Deilye1c9794952013-01-29 00:07:46 -0800212to be generated at several points during a test run. These are normal
213during testing and can be ignored.
214
215It is also recommend to launch IDLE and verify that it is at least
216functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``.
217It should also be tested from the command line::
218
219 /usr/local/bin/idlen.n
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000220