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