Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 1 | Building a Python Mac OS X distribution |
| 2 | ======================================= |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 3 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 4 | The ``build-install.py`` script creates Python distributions, including |
| 5 | certain third-party libraries as necessary. It builds a complete |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 6 | framework-based Python out-of-tree, installs it in a funny place with |
| 7 | $DESTROOT, massages that installation to remove .pyc files and such, creates |
| 8 | an Installer package from the installation plus other files in ``resources`` |
| 9 | and ``scripts`` and placed that on a ``.dmg`` disk image. |
| 10 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 11 | As of Python 3.3.0, PSF practice is to build two installer variants |
| 12 | for each release. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 13 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 14 | 1. 32-bit-only, i386 and PPC universal, capable on running on all machines |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 15 | supported by Mac OS X 10.5 through (at least) 10.8:: |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 16 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 17 | /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) |
| 25 | * SQLite 3.7.13 |
| 26 | * XZ 5.0.3 |
| 27 | |
| 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 | |
| 49 | 2. 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) |
| 59 | * SQLite 3.7.13 |
Ned Deily | 981b693 | 2013-09-06 01:18:36 -0700 | [diff] [blame] | 60 | * Tcl 8.5.14 |
| 61 | * Tk 8.5.14 |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 62 | * XZ 5.0.3 |
| 63 | |
| 64 | - uses system-supplied versions of third-party libraries |
| 65 | |
| 66 | * readline module links with Apple BSD editline (libedit) |
| 67 | |
Ned Deily | 981b693 | 2013-09-06 01:18:36 -0700 | [diff] [blame] | 68 | - requires ActiveState Tcl/Tk 8.5.14 (or later) to be installed for building |
| 69 | |
| 70 | * Beginning with Python 3.4 alpha2, this installer now includes its own |
| 71 | private copy of Tcl and Tk 8.5.14 libraries and thus is no longer |
| 72 | dependent on the buggy releases of Aqua Cocoa Tk 8.5 shipped with |
| 73 | OS X 10.6 or on installing a newer third-party version of Tcl/Tk |
| 74 | in /Library/Frameworks, such as from ActiveState. Because this |
| 75 | is a new feature, it should be considered somewhat experimental and |
| 76 | subject to change prior to the final release of Python 3.4. If it |
| 77 | is necessary to fallback to using a third-party Tcl/Tk because of |
| 78 | a problem with the private Tcl/Tk, there is a backup version of |
| 79 | the _tkinter extension included which will dynamically link to |
| 80 | Tcl and Tk frameworks in /Library/Frameworks as in previous releases. |
| 81 | To enable (for all users of this Python 3.4):: |
| 82 | |
| 83 | sudo bash |
| 84 | cd /Library/Frameworks/Python.framework/Versions/3.4 |
| 85 | cd ./lib/python3.4/lib-dynload |
| 86 | cp -p _tkinter.so.framework _tkinter.so |
| 87 | exit |
| 88 | |
| 89 | To restore using Python's private versions of Tcl and Tk:: |
| 90 | |
| 91 | sudo bash |
| 92 | cd /Library/Frameworks/Python.framework/Versions/3.4 |
| 93 | cd ./lib/python3.4/lib-dynload |
| 94 | cp -p _tkinter.so.private _tkinter.so |
| 95 | exit |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 96 | |
| 97 | - recommended build environment: |
| 98 | |
| 99 | * Mac OS X 10.6.8 (or later) |
| 100 | * Xcode 3.2.6 |
| 101 | * ``MacOSX10.6`` SDK |
| 102 | * ``MACOSX_DEPLOYMENT_TARGET=10.6`` |
| 103 | * Apple ``gcc-4.2`` |
| 104 | * system Python 2.6 for documentation build with Sphinx |
| 105 | |
| 106 | - alternate build environments: |
| 107 | |
| 108 | * none. Xcode 4.x currently supplies two C compilers. |
| 109 | ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and |
| 110 | produce a non-functional Python executable. As it appears to be |
| 111 | considered a migration aid by Apple and is not likely to be fixed, |
| 112 | its use should be avoided. The other compiler, ``clang``, has been |
| 113 | undergoing rapid development. While it appears to have become |
Ned Deily | 981b693 | 2013-09-06 01:18:36 -0700 | [diff] [blame] | 114 | production-ready in the most recent Xcode 4 releases (Xcode 4.6.3 |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 115 | as of this writing), there are still some open issues when |
| 116 | building Python and there has not yet been the level of exposure in |
| 117 | production environments that the Xcode 3 gcc-4.2 compiler has had. |
| 118 | |
| 119 | |
| 120 | * For Python 2.7.x and 3.2.x, the 32-bit-only installer was configured to |
| 121 | support Mac OS X 10.3.9 through (at least) 10.6. Because it is |
| 122 | believed that there are few systems still running OS X 10.3 or 10.4 |
| 123 | and because it has become increasingly difficult to test and |
| 124 | support the differences in these earlier systems, as of Python 3.3.0 the PSF |
| 125 | 32-bit installer no longer supports them. For reference in building such |
| 126 | an installer yourself, the details are:: |
| 127 | |
| 128 | /usr/bin/python build-installer.py \ |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 129 | --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ |
| 130 | --universal-archs=32-bit \ |
| 131 | --dep-target=10.3 |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 132 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 133 | - builds the following third-party libraries |
| 134 | |
| 135 | * Bzip2 |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 136 | * NCurses |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 137 | * GNU Readline (GPL) |
| 138 | * SQLite 3 |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 139 | * XZ |
| 140 | * Zlib 1.2.3 |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 141 | * Oracle Sleepycat DB 4.8 (Python 2.x only) |
| 142 | |
| 143 | - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.19) to be installed for building |
| 144 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 145 | - recommended build environment: |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 146 | |
| 147 | * Mac OS X 10.5.8 PPC or Intel |
| 148 | * Xcode 3.1.4 (or later) |
| 149 | * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) |
| 150 | * ``MACOSX_DEPLOYMENT_TARGET=10.3`` |
| 151 | * Apple ``gcc-4.0`` |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 152 | * system Python 2.5 for documentation build with Sphinx |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 153 | |
| 154 | - alternate build environments: |
| 155 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 156 | * Mac OS X 10.6.8 with Xcode 3.2.6 |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 157 | - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` |
| 158 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 159 | |
| 160 | |
| 161 | General Prerequisites |
| 162 | --------------------- |
| 163 | |
| 164 | * No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local |
| 165 | libraries or utilities (in ``/usr/local``) as they could |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 166 | interfere with the build. |
| 167 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 168 | * The documentation for the release is built using Sphinx |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 169 | because it is included in the installer. |
| 170 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 171 | * It is safest to start each variant build with an empty source directory |
| 172 | populated with a fresh copy of the untarred source. |
| 173 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 174 | * It is recommended that you remove any existing installed version of the |
| 175 | Python being built:: |
| 176 | |
| 177 | sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n |
| 178 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 179 | |
| 180 | The Recipe |
| 181 | ---------- |
| 182 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 183 | Here are the steps you need to follow to build a Python installer: |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 184 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 185 | * Run ``build-installer.py``. Optionally you can pass a number of arguments |
| 186 | to specify locations of various files. Please see the top of |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 187 | ``build-installer.py`` for its usage. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 188 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 189 | Running this script takes some time, it will not only build Python itself |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 190 | but also some 3th-party libraries that are needed for extensions. |
| 191 | |
| 192 | * When done the script will tell you where the DMG image is (by default |
| 193 | somewhere in ``/tmp/_py``). |
| 194 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 195 | Building other universal installers |
| 196 | ................................... |
Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 197 | |
| 198 | It is also possible to build a 4-way universal installer that runs on |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 199 | OS X 10.5 Leopard or later:: |
Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 200 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 201 | /usr/bin/python /build-installer.py \ |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 202 | --dep-target=10.5 |
| 203 | --universal-archs=all |
| 204 | --sdk-path=/Developer/SDKs/MacOSX10.5.sdk |
Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 205 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 206 | This requires that the deployment target is 10.5, and hence |
| 207 | also that you are building on at least OS X 10.5. 4-way includes |
| 208 | ``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable |
| 209 | variants can only be run on G5 machines running 10.5. Note that, |
| 210 | while OS X 10.6 is only supported on Intel-based machines, it is possible |
| 211 | to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 212 | emulation in OS X 10.5 and 10.6. The 4-way installer variant must be |
| 213 | built with Xcode 3. It is not regularly built or tested. |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 214 | |
| 215 | Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), |
| 216 | and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options |
| 217 | are regularly exercised; use at your own risk. |
| 218 | |
Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 219 | |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 220 | Testing |
| 221 | ------- |
| 222 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 223 | Ideally, the resulting binaries should be installed and the test suite run |
| 224 | on all supported OS X releases and architectures. As a practical matter, |
| 225 | that is generally not possible. At a minimum, variant 1 should be run on |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 226 | a PPC G4 system with OS X 10.5 and at least one Intel system running OS X |
| 227 | 10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 |
| 228 | systems in both 32-bit and 64-bit modes.:: |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 229 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 230 | /usr/local/bin/pythonn.n -m test -w -u all,-largefile |
| 231 | /usr/local/bin/pythonn.n-32 -m test -w -u all |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 232 | |
| 233 | Certain tests will be skipped and some cause the interpreter to fail |
| 234 | which will likely generate ``Python quit unexpectedly`` alert messages |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 235 | to be generated at several points during a test run. These are normal |
| 236 | during testing and can be ignored. |
| 237 | |
| 238 | It is also recommend to launch IDLE and verify that it is at least |
| 239 | functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. |
| 240 | It should also be tested from the command line:: |
| 241 | |
| 242 | /usr/local/bin/idlen.n |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 243 | |