blob: 0a6b54455764f090432c749f5df122adbd0bf244 [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 Deily22726702011-01-15 04:44:12 +00004The ``build-install.py`` script creates Python distributions, including
5certain 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 Deily9fa4ced2013-11-22 22:54:02 -080011For Python 3.4.0, PSF practice is to build two installer variants
Ned Deily5c0b1ca2012-08-24 19:57:33 -070012for each release.
Thomas Wouters477c8d52006-05-27 19:21:47 +000013
Ned Deily22726702011-01-15 04:44:12 +0000141. 32-bit-only, i386 and PPC universal, capable on running on all machines
Ned Deily5c0b1ca2012-08-24 19:57:33 -070015 supported by Mac OS X 10.5 through (at least) 10.8::
Thomas Wouters0e3f5912006-08-11 14:57:12 +000016
Ned Deily5c0b1ca2012-08-24 19:57:33 -070017 /usr/bin/python build-installer.py \
18 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \
19 --universal-archs=32-bit \
20 --dep-target=10.5
21
22 - builds the following third-party libraries
23
24 * NCurses 5.9 (http://bugs.python.org/issue15037)
Ned Deily9fa4ced2013-11-22 22:54:02 -080025 * SQLite 3.8.1
26 * XZ 5.0.5
Ned Deily5c0b1ca2012-08-24 19:57:33 -070027
28 - uses system-supplied versions of third-party libraries
29
30 * readline module links with Apple BSD editline (libedit)
31
32 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building
33
34 - recommended build environment:
35
36 * Mac OS X 10.5.8 Intel or PPC
37 * Xcode 3.1.4
38 * ``MacOSX10.5`` SDK
39 * ``MACOSX_DEPLOYMENT_TARGET=10.5``
40 * Apple ``gcc-4.2``
41 * system Python 2.5 for documentation build with Sphinx
42
43 - alternate build environments:
44
45 * Mac OS X 10.6.8 with Xcode 3.2.6
46 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
47 * Note Xcode 4.* does not support building for PPC so cannot be used for this build
48
492. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later)::
50
51 /usr/bin/python build-installer.py \
52 --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \
53 --universal-archs=intel \
54 --dep-target=10.6
55
56 - builds the following third-party libraries
57
58 * NCurses 5.9 (http://bugs.python.org/issue15037)
Ned Deily9fa4ced2013-11-22 22:54:02 -080059 * SQLite 3.8.1
Ned Deily9fa4ced2013-11-22 22:54:02 -080060 * XZ 5.0.5
Ned Deily5c0b1ca2012-08-24 19:57:33 -070061
62 - uses system-supplied versions of third-party libraries
63
64 * readline module links with Apple BSD editline (libedit)
65
Ned Deilyea41d5f2013-10-18 20:49:27 -070066 - requires ActiveState Tcl/Tk 8.5.15 (or later) to be installed for building
Ned Deily981b6932013-09-06 01:18:36 -070067
Ned Deily5c0b1ca2012-08-24 19:57:33 -070068 - recommended build environment:
69
70 * Mac OS X 10.6.8 (or later)
71 * Xcode 3.2.6
72 * ``MacOSX10.6`` SDK
73 * ``MACOSX_DEPLOYMENT_TARGET=10.6``
74 * Apple ``gcc-4.2``
75 * system Python 2.6 for documentation build with Sphinx
76
77 - alternate build environments:
78
79 * none. Xcode 4.x currently supplies two C compilers.
80 ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and
81 produce a non-functional Python executable. As it appears to be
82 considered a migration aid by Apple and is not likely to be fixed,
83 its use should be avoided. The other compiler, ``clang``, has been
84 undergoing rapid development. While it appears to have become
Ned Deily981b6932013-09-06 01:18:36 -070085 production-ready in the most recent Xcode 4 releases (Xcode 4.6.3
Ned Deily5c0b1ca2012-08-24 19:57:33 -070086 as of this writing), there are still some open issues when
87 building Python and there has not yet been the level of exposure in
88 production environments that the Xcode 3 gcc-4.2 compiler has had.
89
90
91* For Python 2.7.x and 3.2.x, the 32-bit-only installer was configured to
92 support Mac OS X 10.3.9 through (at least) 10.6. Because it is
93 believed that there are few systems still running OS X 10.3 or 10.4
94 and because it has become increasingly difficult to test and
95 support the differences in these earlier systems, as of Python 3.3.0 the PSF
96 32-bit installer no longer supports them. For reference in building such
97 an installer yourself, the details are::
98
99 /usr/bin/python build-installer.py \
Ned Deily22726702011-01-15 04:44:12 +0000100 --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \
101 --universal-archs=32-bit \
102 --dep-target=10.3
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000103
Ned Deily22726702011-01-15 04:44:12 +0000104 - builds the following third-party libraries
105
106 * Bzip2
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700107 * NCurses
Ned Deily22726702011-01-15 04:44:12 +0000108 * GNU Readline (GPL)
109 * SQLite 3
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700110 * XZ
111 * Zlib 1.2.3
Ned Deily22726702011-01-15 04:44:12 +0000112 * Oracle Sleepycat DB 4.8 (Python 2.x only)
113
114 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building
115
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700116 - recommended build environment:
Ned Deily22726702011-01-15 04:44:12 +0000117
118 * Mac OS X 10.5.8 PPC or Intel
119 * Xcode 3.1.4 (or later)
120 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors)
121 * ``MACOSX_DEPLOYMENT_TARGET=10.3``
122 * Apple ``gcc-4.0``
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700123 * system Python 2.5 for documentation build with Sphinx
Ned Deily22726702011-01-15 04:44:12 +0000124
125 - alternate build environments:
126
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700127 * Mac OS X 10.6.8 with Xcode 3.2.6
Ned Deily22726702011-01-15 04:44:12 +0000128 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
129
Ned Deily22726702011-01-15 04:44:12 +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
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000137 interfere with the build.
138
Ned Deily22726702011-01-15 04:44:12 +0000139* The documentation for the release is built using Sphinx
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000140 because it is included in the installer.
141
Ned Deily22726702011-01-15 04:44:12 +0000142* It is safest to start each variant build with an empty source directory
143 populated with a fresh copy of the untarred source.
144
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700145* It is recommended that you remove any existing installed version of the
146 Python being built::
147
148 sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n
149
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000150
151The Recipe
152----------
153
Ned Deily22726702011-01-15 04:44:12 +0000154Here are the steps you need to follow to build a Python installer:
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000155
Ned Deily22726702011-01-15 04:44:12 +0000156* Run ``build-installer.py``. Optionally you can pass a number of arguments
157 to specify locations of various files. Please see the top of
Thomas Wouters477c8d52006-05-27 19:21:47 +0000158 ``build-installer.py`` for its usage.
Thomas Wouters477c8d52006-05-27 19:21:47 +0000159
Ned Deily22726702011-01-15 04:44:12 +0000160 Running this script takes some time, it will not only build Python itself
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000161 but also some 3th-party libraries that are needed for extensions.
162
163* When done the script will tell you where the DMG image is (by default
164 somewhere in ``/tmp/_py``).
165
Ned Deily22726702011-01-15 04:44:12 +0000166Building other universal installers
167...................................
Ronald Oussoren1943f862009-03-30 19:39:14 +0000168
169It is also possible to build a 4-way universal installer that runs on
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700170OS X 10.5 Leopard or later::
Ronald Oussoren1943f862009-03-30 19:39:14 +0000171
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700172 /usr/bin/python /build-installer.py \
Ned Deily22726702011-01-15 04:44:12 +0000173 --dep-target=10.5
174 --universal-archs=all
175 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk
Ronald Oussoren1943f862009-03-30 19:39:14 +0000176
Ned Deily22726702011-01-15 04:44:12 +0000177This requires that the deployment target is 10.5, and hence
178also that you are building on at least OS X 10.5. 4-way includes
179``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable
180variants can only be run on G5 machines running 10.5. Note that,
181while OS X 10.6 is only supported on Intel-based machines, it is possible
182to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700183emulation in OS X 10.5 and 10.6. The 4-way installer variant must be
184built with Xcode 3. It is not regularly built or tested.
Ned Deily22726702011-01-15 04:44:12 +0000185
186Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``),
187and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options
188are regularly exercised; use at your own risk.
189
Ronald Oussoren1943f862009-03-30 19:39:14 +0000190
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000191Testing
192-------
193
Ned Deily22726702011-01-15 04:44:12 +0000194Ideally, the resulting binaries should be installed and the test suite run
195on all supported OS X releases and architectures. As a practical matter,
196that is generally not possible. At a minimum, variant 1 should be run on
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700197a PPC G4 system with OS X 10.5 and at least one Intel system running OS X
19810.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6
199systems in both 32-bit and 64-bit modes.::
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000200
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700201 /usr/local/bin/pythonn.n -m test -w -u all,-largefile
202 /usr/local/bin/pythonn.n-32 -m test -w -u all
Ned Deily22726702011-01-15 04:44:12 +0000203
204Certain tests will be skipped and some cause the interpreter to fail
205which will likely generate ``Python quit unexpectedly`` alert messages
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700206to be generated at several points during a test run. These are normal
207during testing and can be ignored.
208
209It is also recommend to launch IDLE and verify that it is at least
210functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``.
211It should also be tested from the command line::
212
213 /usr/local/bin/idlen.n
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000214