blob: 3612cd017f2a6b62f74ea578e04860ed7af48e62 [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 Deilye1c9794952013-01-29 00:07:46 -080011For Python 2.7.x and 3.2.x, PSF practice is to build two installer variants
12for each release.
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +000013
Ned Deily53c460d2011-01-30 01:43:40 +0000141. 32-bit-only, i386 and PPC universal, capable on running on all machines
Ned Deilye1c9794952013-01-29 00:07:46 -080015 supported by Mac OS X 10.3.9 through (at least) 10.8::
Ronald Oussoren5fb9c202006-08-02 06:10:10 +000016
Ned Deilye1c9794952013-01-29 00:07:46 -080017 /usr/bin/python build-installer.py \
Ned Deily53c460d2011-01-30 01:43:40 +000018 --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \
19 --universal-archs=32-bit \
20 --dep-target=10.3
Ronald Oussoren5fb9c202006-08-02 06:10:10 +000021
Ned Deily53c460d2011-01-30 01:43:40 +000022 - builds the following third-party libraries
23
24 * Bzip2
Ned Deily53c460d2011-01-30 01:43:40 +000025 * NCurses
Ned Deilye1c9794952013-01-29 00:07:46 -080026 * GNU Readline (GPL)
27 * SQLite 3.7.13
28 * Zlib 1.2.3
Ned Deily53c460d2011-01-30 01:43:40 +000029 * Oracle Sleepycat DB 4.8 (Python 2.x only)
30
31 - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building
32
Ned Deilye1c9794952013-01-29 00:07:46 -080033 - recommended build environment:
Ned Deily53c460d2011-01-30 01:43:40 +000034
35 * Mac OS X 10.5.8 PPC or Intel
Ned Deilye1c9794952013-01-29 00:07:46 -080036 * Xcode 3.1.4
Ned Deily53c460d2011-01-30 01:43:40 +000037 * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors)
38 * ``MACOSX_DEPLOYMENT_TARGET=10.3``
39 * Apple ``gcc-4.0``
Ned Deilye1c9794952013-01-29 00:07:46 -080040 * system Python 2.5 for documentation build with Sphinx
Ned Deily53c460d2011-01-30 01:43:40 +000041
42 - alternate build environments:
43
Ned Deilye1c9794952013-01-29 00:07:46 -080044 * Mac OS X 10.6.8 with Xcode 3.2.6
Ned Deily53c460d2011-01-30 01:43:40 +000045 - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4``
Ned Deilye1c9794952013-01-29 00:07:46 -080046 * Note Xcode 4.* does not support building for PPC so cannot be used for this build
47
Ned Deily53c460d2011-01-30 01:43:40 +000048
492. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later)::
50
Ned Deilye1c9794952013-01-29 00:07:46 -080051 /usr/bin/python build-installer.py \
Ned Deily53c460d2011-01-30 01:43:40 +000052 --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \
53 --universal-archs=intel \
54 --dep-target=10.6
55
Ned Deilye1c9794952013-01-29 00:07:46 -080056 - builds the following third-party libraries
57
58 * NCurses 5.9 (http://bugs.python.org/issue15037)
59 * SQLite 3.7.13
Ned Deily0203a802013-10-25 00:40:07 -070060 * Tcl 8.5.15
Ned Deilye1c9794952013-01-29 00:07:46 -080061
Ned Deily53c460d2011-01-30 01:43:40 +000062 - uses system-supplied versions of third-party libraries
Ned Deilye1c9794952013-01-29 00:07:46 -080063
Ned Deily53c460d2011-01-30 01:43:40 +000064 * readline module links with Apple BSD editline (libedit)
65 * builds Oracle Sleepycat DB 4.8 (Python 2.x only)
66
Ned Deily0203a802013-10-25 00:40:07 -070067 - requires ActiveState Tcl/Tk 8.5.14 (or later) to be installed for building
68
69 * Beginning with Python 2.7.6, this installer now includes its own
Ned Deily70f213a2013-10-26 03:16:06 -070070 builtin copy of Tcl and Tk 8.5.15 libraries and thus is no longer
Ned Deily0203a802013-10-25 00:40:07 -070071 dependent on the buggy releases of Aqua Cocoa Tk 8.5 shipped with
72 OS X 10.6 or on installing a newer third-party version of Tcl/Tk
73 in /Library/Frameworks, such as from ActiveState. If it is
74 necessary to fallback to using a third-party Tcl/Tk because of
Ned Deily70f213a2013-10-26 03:16:06 -070075 a problem with the builtin Tcl/Tk, there is a backup version of
Ned Deily0203a802013-10-25 00:40:07 -070076 the _tkinter extension included which will dynamically link to
77 Tcl and Tk frameworks in /Library/Frameworks as in previous releases.
78 To enable (for all users of this Python 2.7)::
79
80 sudo bash
81 cd /Library/Frameworks/Python.framework/Versions/2.7
Ned Deily70f213a2013-10-26 03:16:06 -070082 cd ./lib/python2.7
83 cp -p ./lib-tkinter/library/_tkinter.so ./lib-dynload
Ned Deily0203a802013-10-25 00:40:07 -070084 exit
85
Ned Deily70f213a2013-10-26 03:16:06 -070086 To restore using Python's builtin versions of Tcl and Tk::
Ned Deily0203a802013-10-25 00:40:07 -070087
88 sudo bash
89 cd /Library/Frameworks/Python.framework/Versions/2.7
Ned Deily70f213a2013-10-26 03:16:06 -070090 cd ./lib/python2.7
91 cp -p ./lib-tkinter/builtin/_tkinter.so ./lib-dynload
Ned Deily0203a802013-10-25 00:40:07 -070092 exit
Ned Deily53c460d2011-01-30 01:43:40 +000093
Ned Deilye1c9794952013-01-29 00:07:46 -080094 - recommended build environment:
95
96 * Mac OS X 10.6.8 (or later)
97 * Xcode 3.2.6
Ned Deily53c460d2011-01-30 01:43:40 +000098 * ``MacOSX10.6`` SDK
99 * ``MACOSX_DEPLOYMENT_TARGET=10.6``
100 * Apple ``gcc-4.2``
Ned Deilye1c9794952013-01-29 00:07:46 -0800101 * system Python 2.6 for documentation build with Sphinx
Ned Deily53c460d2011-01-30 01:43:40 +0000102
103 - alternate build environments:
104
Ned Deilye1c9794952013-01-29 00:07:46 -0800105 * none. Xcode 4.x currently supplies two C compilers.
106 ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and
107 produce a non-functional Python executable. As it appears to be
108 considered a migration aid by Apple and is not likely to be fixed,
109 its use should be avoided. The other compiler, ``clang``, has been
110 undergoing rapid development. While it appears to have become
111 production-ready in the most recent Xcode 4 releases (Xcode 4.5.x
112 as of this writing), there are still some open issues when
113 building Python and there has not yet been the level of exposure in
114 production environments that the Xcode 3 gcc-4.2 compiler has had.
Ned Deily53c460d2011-01-30 01:43:40 +0000115
116
117General Prerequisites
118---------------------
119
120* No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local
121 libraries or utilities (in ``/usr/local``) as they could
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000122 interfere with the build.
123
Ned Deily53c460d2011-01-30 01:43:40 +0000124* The documentation for the release is built using Sphinx
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000125 because it is included in the installer.
126
Ned Deily53c460d2011-01-30 01:43:40 +0000127* It is safest to start each variant build with an empty source directory
128 populated with a fresh copy of the untarred source.
129
Ned Deilye1c9794952013-01-29 00:07:46 -0800130* It is recommended that you remove any existing installed version of the
131 Python being built::
132
133 sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n
134
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000135
136The Recipe
137----------
138
Ned Deily53c460d2011-01-30 01:43:40 +0000139Here are the steps you need to follow to build a Python installer:
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000140
Ned Deily53c460d2011-01-30 01:43:40 +0000141* Run ``build-installer.py``. Optionally you can pass a number of arguments
142 to specify locations of various files. Please see the top of
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +0000143 ``build-installer.py`` for its usage.
Ronald Oussoren0e5b70d2006-06-07 18:58:42 +0000144
Ned Deily53c460d2011-01-30 01:43:40 +0000145 Running this script takes some time, it will not only build Python itself
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000146 but also some 3th-party libraries that are needed for extensions.
147
148* When done the script will tell you where the DMG image is (by default
149 somewhere in ``/tmp/_py``).
150
Ned Deily53c460d2011-01-30 01:43:40 +0000151Building other universal installers
152...................................
Ronald Oussoren508282e2009-03-30 19:34:51 +0000153
154It is also possible to build a 4-way universal installer that runs on
Ned Deilye1c9794952013-01-29 00:07:46 -0800155OS X 10.5 Leopard or later::
Ronald Oussoren508282e2009-03-30 19:34:51 +0000156
Ned Deilye1c9794952013-01-29 00:07:46 -0800157 /usr/bin/python /build-installer.py \
Ned Deily53c460d2011-01-30 01:43:40 +0000158 --dep-target=10.5
159 --universal-archs=all
160 --sdk-path=/Developer/SDKs/MacOSX10.5.sdk
Ronald Oussoren508282e2009-03-30 19:34:51 +0000161
Ned Deily53c460d2011-01-30 01:43:40 +0000162This requires that the deployment target is 10.5, and hence
163also that you are building on at least OS X 10.5. 4-way includes
164``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable
165variants can only be run on G5 machines running 10.5. Note that,
166while OS X 10.6 is only supported on Intel-based machines, it is possible
167to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc
Ned Deilye1c9794952013-01-29 00:07:46 -0800168emulation in OS X 10.5 and 10.6. The 4-way installer variant must be
169built with Xcode 3. It is not regularly built or tested.
Ned Deily53c460d2011-01-30 01:43:40 +0000170
171Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``),
172and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options
173are regularly exercised; use at your own risk.
174
Ronald Oussoren508282e2009-03-30 19:34:51 +0000175
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000176Testing
177-------
178
Ned Deily53c460d2011-01-30 01:43:40 +0000179Ideally, the resulting binaries should be installed and the test suite run
180on all supported OS X releases and architectures. As a practical matter,
181that is generally not possible. At a minimum, variant 1 should be run on
Ned Deilye1c9794952013-01-29 00:07:46 -0800182a PPC G4 system with OS X 10.5 and at least one Intel system running OS X
18310.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6
184systems in both 32-bit and 64-bit modes.::
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000185
Ned Deilye1c9794952013-01-29 00:07:46 -0800186 /usr/local/bin/pythonn.n -m test -w -u all,-largefile
187 /usr/local/bin/pythonn.n-32 -m test -w -u all
Ned Deily53c460d2011-01-30 01:43:40 +0000188
189Certain tests will be skipped and some cause the interpreter to fail
190which will likely generate ``Python quit unexpectedly`` alert messages
Ned Deilye1c9794952013-01-29 00:07:46 -0800191to be generated at several points during a test run. These are normal
192during testing and can be ignored.
193
194It is also recommend to launch IDLE and verify that it is at least
195functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``.
196It should also be tested from the command line::
197
198 /usr/local/bin/idlen.n
Ronald Oussoren5fb9c202006-08-02 06:10:10 +0000199