Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 1 | Building a Python Mac OS X distribution |
| 2 | ======================================= |
Ronald Oussoren | 0e5b70d | 2006-06-07 18:58:42 +0000 | [diff] [blame] | 3 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 4 | The ``build-install.py`` script creates Python distributions, including |
| 5 | certain third-party libraries as necessary. It builds a complete |
Ronald Oussoren | 0e5b70d | 2006-06-07 18:58:42 +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 | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 11 | For Python 2.7.x and 3.x, PSF practice is to build two installer variants |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 12 | for each release. |
Ronald Oussoren | 0e5b70d | 2006-06-07 18:58:42 +0000 | [diff] [blame] | 13 | |
Ned Deily | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 14 | Beginning with Python 2.7.8, we plan to drop binary installer support for |
| 15 | Mac OS X 10.3.9 and 10.4.x systems. To ease the transition, for Python 2.7.7 |
| 16 | only there will be three installers provided: |
| 17 | |
| 18 | 1. 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 Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 20 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 21 | /usr/bin/python build-installer.py \ |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 22 | --sdk-path=/Developer/SDKs/MacOSX10.4u.sdk \ |
| 23 | --universal-archs=32-bit \ |
| 24 | --dep-target=10.3 |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 25 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 26 | - builds the following third-party libraries |
| 27 | |
| 28 | * Bzip2 |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 29 | * NCurses |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 30 | * GNU Readline (GPL) |
| 31 | * SQLite 3.7.13 |
| 32 | * Zlib 1.2.3 |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 33 | * 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 Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 37 | - recommended build environment: |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 38 | |
| 39 | * Mac OS X 10.5.8 PPC or Intel |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 40 | * Xcode 3.1.4 |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 41 | * ``MacOSX10.4u`` SDK (later SDKs do not support PPC G3 processors) |
| 42 | * ``MACOSX_DEPLOYMENT_TARGET=10.3`` |
| 43 | * Apple ``gcc-4.0`` |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 44 | * system Python 2.5 for documentation build with Sphinx |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 45 | |
| 46 | - alternate build environments: |
| 47 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 48 | * Mac OS X 10.6.8 with Xcode 3.2.6 |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 49 | - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 50 | * Note Xcode 4.* does not support building for PPC so cannot be used for this build |
| 51 | |
Ned Deily | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 52 | 2. 32-bit-only, i386 and PPC universal, capable on running on all machines |
| 53 | supported by Mac OS X 10.5 through (at least) 10.9:: |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 54 | |
Ned Deily | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 55 | /usr/bin/python build-installer.py \ |
| 56 | --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \ |
| 57 | --universal-archs=32-bit \ |
| 58 | --dep-target=10.5 |
| 59 | |
| 60 | - builds the following third-party libraries |
| 61 | |
| 62 | * NCurses 5.9 |
| 63 | * SQLite 3.7.13 |
| 64 | * Oracle Sleepycat DB 4.8 (Python 2.x only) |
| 65 | |
| 66 | - uses system-supplied versions of third-party libraries |
| 67 | |
| 68 | * readline module links with Apple BSD editline (libedit) |
| 69 | |
| 70 | - requires ActiveState ``Tcl/Tk 8.4`` (currently 8.4.20) to be installed for building |
| 71 | |
| 72 | - recommended build environment: |
| 73 | |
| 74 | * Mac OS X 10.5.8 Intel or PPC |
| 75 | * Xcode 3.1.4 |
| 76 | * ``MacOSX10.5`` SDK |
| 77 | * ``MACOSX_DEPLOYMENT_TARGET=10.5`` |
| 78 | * Apple ``gcc-4.2`` |
| 79 | * system Python 2.5+ for documentation build with Sphinx |
| 80 | |
| 81 | - alternate build environments: |
| 82 | |
| 83 | * Mac OS X 10.6.8 with Xcode 3.2.6 |
| 84 | - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` |
| 85 | * Note Xcode 4.* does not support building for PPC so cannot be used for this build |
| 86 | |
| 87 | 3. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 88 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 89 | /usr/bin/python build-installer.py \ |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 90 | --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ |
| 91 | --universal-archs=intel \ |
| 92 | --dep-target=10.6 |
| 93 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 94 | - builds the following third-party libraries |
| 95 | |
| 96 | * NCurses 5.9 (http://bugs.python.org/issue15037) |
| 97 | * SQLite 3.7.13 |
Ned Deily | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 98 | * Oracle Sleepycat DB 4.8 (Python 2.x only) |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 99 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 100 | - uses system-supplied versions of third-party libraries |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 101 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 102 | * readline module links with Apple BSD editline (libedit) |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 103 | |
Ned Deily | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 104 | - requires ActiveState Tcl/Tk 8.5.15 (or later) to be installed for building |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 105 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 106 | - recommended build environment: |
| 107 | |
| 108 | * Mac OS X 10.6.8 (or later) |
| 109 | * Xcode 3.2.6 |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 110 | * ``MacOSX10.6`` SDK |
| 111 | * ``MACOSX_DEPLOYMENT_TARGET=10.6`` |
| 112 | * Apple ``gcc-4.2`` |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 113 | * system Python 2.6 for documentation build with Sphinx |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 114 | |
| 115 | - alternate build environments: |
| 116 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 117 | * none. Xcode 4.x currently supplies two C compilers. |
| 118 | ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and |
| 119 | produce a non-functional Python executable. As it appears to be |
| 120 | considered a migration aid by Apple and is not likely to be fixed, |
| 121 | its use should be avoided. The other compiler, ``clang``, has been |
| 122 | undergoing rapid development. While it appears to have become |
Ned Deily | 78cceec | 2014-05-17 14:29:22 -0700 | [diff] [blame^] | 123 | production-ready in the most recent Xcode 5 releases, the versions |
| 124 | available on the deprecated Xcode 4.x for 10.6 were early releases |
| 125 | and did not receive the level of exposure in production environments |
| 126 | that the Xcode 3 gcc-4.2 compiler has had. |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 127 | |
| 128 | |
| 129 | General Prerequisites |
| 130 | --------------------- |
| 131 | |
| 132 | * No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local |
| 133 | libraries or utilities (in ``/usr/local``) as they could |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 134 | interfere with the build. |
| 135 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 136 | * The documentation for the release is built using Sphinx |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 137 | because it is included in the installer. |
| 138 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 139 | * It is safest to start each variant build with an empty source directory |
| 140 | populated with a fresh copy of the untarred source. |
| 141 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 142 | * It is recommended that you remove any existing installed version of the |
| 143 | Python being built:: |
| 144 | |
| 145 | sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n |
| 146 | |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 147 | |
| 148 | The Recipe |
| 149 | ---------- |
| 150 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 151 | Here are the steps you need to follow to build a Python installer: |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 152 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 153 | * Run ``build-installer.py``. Optionally you can pass a number of arguments |
| 154 | to specify locations of various files. Please see the top of |
Ronald Oussoren | 0e5b70d | 2006-06-07 18:58:42 +0000 | [diff] [blame] | 155 | ``build-installer.py`` for its usage. |
Ronald Oussoren | 0e5b70d | 2006-06-07 18:58:42 +0000 | [diff] [blame] | 156 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 157 | Running this script takes some time, it will not only build Python itself |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 158 | but also some 3th-party libraries that are needed for extensions. |
| 159 | |
| 160 | * When done the script will tell you where the DMG image is (by default |
| 161 | somewhere in ``/tmp/_py``). |
| 162 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 163 | Building other universal installers |
| 164 | ................................... |
Ronald Oussoren | 508282e | 2009-03-30 19:34:51 +0000 | [diff] [blame] | 165 | |
| 166 | It is also possible to build a 4-way universal installer that runs on |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 167 | OS X 10.5 Leopard or later:: |
Ronald Oussoren | 508282e | 2009-03-30 19:34:51 +0000 | [diff] [blame] | 168 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 169 | /usr/bin/python /build-installer.py \ |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 170 | --dep-target=10.5 |
| 171 | --universal-archs=all |
| 172 | --sdk-path=/Developer/SDKs/MacOSX10.5.sdk |
Ronald Oussoren | 508282e | 2009-03-30 19:34:51 +0000 | [diff] [blame] | 173 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 174 | This requires that the deployment target is 10.5, and hence |
| 175 | also that you are building on at least OS X 10.5. 4-way includes |
| 176 | ``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable |
| 177 | variants can only be run on G5 machines running 10.5. Note that, |
| 178 | while OS X 10.6 is only supported on Intel-based machines, it is possible |
| 179 | to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 180 | emulation in OS X 10.5 and 10.6. The 4-way installer variant must be |
| 181 | built with Xcode 3. It is not regularly built or tested. |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 182 | |
| 183 | Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), |
| 184 | and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options |
| 185 | are regularly exercised; use at your own risk. |
| 186 | |
Ronald Oussoren | 508282e | 2009-03-30 19:34:51 +0000 | [diff] [blame] | 187 | |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 188 | Testing |
| 189 | ------- |
| 190 | |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 191 | Ideally, the resulting binaries should be installed and the test suite run |
| 192 | on all supported OS X releases and architectures. As a practical matter, |
| 193 | that is generally not possible. At a minimum, variant 1 should be run on |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 194 | a PPC G4 system with OS X 10.5 and at least one Intel system running OS X |
| 195 | 10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.8, 10.7, and 10.6 |
| 196 | systems in both 32-bit and 64-bit modes.:: |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 197 | |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 198 | /usr/local/bin/pythonn.n -m test -w -u all,-largefile |
| 199 | /usr/local/bin/pythonn.n-32 -m test -w -u all |
Ned Deily | 53c460d | 2011-01-30 01:43:40 +0000 | [diff] [blame] | 200 | |
| 201 | Certain tests will be skipped and some cause the interpreter to fail |
| 202 | which will likely generate ``Python quit unexpectedly`` alert messages |
Ned Deily | e1c979495 | 2013-01-29 00:07:46 -0800 | [diff] [blame] | 203 | to be generated at several points during a test run. These are normal |
| 204 | during testing and can be ignored. |
| 205 | |
| 206 | It is also recommend to launch IDLE and verify that it is at least |
| 207 | functional. Double-click on the IDLE app icon in ``/Applications/Pythonn.n``. |
| 208 | It should also be tested from the command line:: |
| 209 | |
| 210 | /usr/local/bin/idlen.n |
Ronald Oussoren | 5fb9c20 | 2006-08-02 06:10:10 +0000 | [diff] [blame] | 211 | |