| 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 | fc4ead2 | 2014-09-19 21:03:45 -0700 | [diff] [blame] | 4 | The ``build-installer.py`` script creates Python distributions, including |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 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 | fc4ead2 | 2014-09-19 21:03:45 -0700 | [diff] [blame] | 11 | This installers built by this script are legacy bundle installers that have |
| 12 | been supported from the early days of OS X. In particular, they are supported |
| 13 | on OS X 10.3.9, the earliest supported release for builds from this script. |
| 14 | |
| 15 | Beginning with Python 3.4.2, PSF practice is to build two installer variants |
| 16 | using the newer flat package format, supported on 10.5+, and signed with the |
| 17 | builder's Apple developer key, allowing downloaded packages to satisfy Apple's |
| 18 | default Gatekeeper policy (e.g. starting with 10.8, Apple store downloads and |
| 19 | Apple developer ID signed apps and installer packages). The process for |
| 20 | transforming the output build artifacts into signed flat packages is not |
| 21 | yet integrated into ``build-installer.py``. The steps prior to the flat |
| 22 | package creation are the same as for 3.4.1 below. |
| 23 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 24 | 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] | 25 | supported by Mac OS X 10.5 through (at least) 10.9:: |
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 26 | |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 27 | /path/to/bootstrap/python2.7 build-installer.py \ |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 28 | --sdk-path=/Developer/SDKs/MacOSX10.5.sdk \ |
| 29 | --universal-archs=32-bit \ |
| 30 | --dep-target=10.5 |
| 31 | |
| 32 | - builds the following third-party libraries |
| 33 | |
| Ned Deily | 54362ca | 2015-01-09 13:30:11 -0800 | [diff] [blame] | 34 | * libcrypto and libssl from OpenSSL 1.0.1 (new, as of 3.4.3) |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 35 | * NCurses 5.9 (http://bugs.python.org/issue15037) |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 36 | * SQLite 3.8.3.1 |
| Ned Deily | 9fa4ced | 2013-11-22 22:54:02 -0800 | [diff] [blame] | 37 | * XZ 5.0.5 |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 38 | |
| 39 | - uses system-supplied versions of third-party libraries |
| 40 | |
| 41 | * readline module links with Apple BSD editline (libedit) |
| 42 | |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 43 | - 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] | 44 | |
| 45 | - recommended build environment: |
| 46 | |
| 47 | * Mac OS X 10.5.8 Intel or PPC |
| 48 | * Xcode 3.1.4 |
| 49 | * ``MacOSX10.5`` SDK |
| 50 | * ``MACOSX_DEPLOYMENT_TARGET=10.5`` |
| 51 | * Apple ``gcc-4.2`` |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 52 | * bootstrap non-framework Python 2.7 for documentation build with |
| 53 | Sphinx (as of 3.4.1) |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 54 | |
| 55 | - alternate build environments: |
| 56 | |
| 57 | * Mac OS X 10.6.8 with Xcode 3.2.6 |
| 58 | - need to change ``/System/Library/Frameworks/{Tcl,Tk}.framework/Version/Current`` to ``8.4`` |
| 59 | * Note Xcode 4.* does not support building for PPC so cannot be used for this build |
| 60 | |
| 61 | 2. 64-bit / 32-bit, x86_64 and i386 universal, for OS X 10.6 (and later):: |
| 62 | |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 63 | /path/to/bootstrap/python2.7 build-installer.py \ |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 64 | --sdk-path=/Developer/SDKs/MacOSX10.6.sdk \ |
| 65 | --universal-archs=intel \ |
| 66 | --dep-target=10.6 |
| 67 | |
| 68 | - builds the following third-party libraries |
| 69 | |
| 70 | * NCurses 5.9 (http://bugs.python.org/issue15037) |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 71 | * SQLite 3.8.3.1 |
| Ned Deily | 9fa4ced | 2013-11-22 22:54:02 -0800 | [diff] [blame] | 72 | * XZ 5.0.5 |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 73 | |
| 74 | - uses system-supplied versions of third-party libraries |
| 75 | |
| Ned Deily | 54362ca | 2015-01-09 13:30:11 -0800 | [diff] [blame] | 76 | * libcrypto and libssl from Apple OpenSSL 0.9.8 |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 77 | * readline module links with Apple BSD editline (libedit) |
| 78 | |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 79 | - 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] | 80 | |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 81 | - recommended build environment: |
| 82 | |
| 83 | * Mac OS X 10.6.8 (or later) |
| 84 | * Xcode 3.2.6 |
| 85 | * ``MacOSX10.6`` SDK |
| 86 | * ``MACOSX_DEPLOYMENT_TARGET=10.6`` |
| 87 | * Apple ``gcc-4.2`` |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 88 | * bootstrap non-framework Python 2.7 for documentation build with |
| 89 | Sphinx (as of 3.4.1) |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 90 | |
| 91 | - alternate build environments: |
| 92 | |
| 93 | * none. Xcode 4.x currently supplies two C compilers. |
| 94 | ``llvm-gcc-4.2.1`` has been found to miscompile Python 3.3.x and |
| 95 | produce a non-functional Python executable. As it appears to be |
| 96 | considered a migration aid by Apple and is not likely to be fixed, |
| 97 | its use should be avoided. The other compiler, ``clang``, has been |
| 98 | undergoing rapid development. While it appears to have become |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 99 | production-ready in the most recent Xcode 5 releases, the versions |
| 100 | available on the deprecated Xcode 4.x for 10.6 were early releases |
| 101 | and did not receive the level of exposure in production environments |
| 102 | that the Xcode 3 gcc-4.2 compiler has had. |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 103 | |
| 104 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 105 | General Prerequisites |
| 106 | --------------------- |
| 107 | |
| 108 | * No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or other local |
| 109 | libraries or utilities (in ``/usr/local``) as they could |
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 110 | interfere with the build. |
| 111 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 112 | * The documentation for the release is built using Sphinx |
| Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 113 | because it is included in the installer. For 2.7.x and 3.x.x up to and |
| 114 | including 3.4.0, the ``Doc/Makefile`` uses ``svn`` to download repos of |
| 115 | ``Sphinx`` and its dependencies. Beginning with 3.4.1, the ``Doc/Makefile`` |
| 116 | assumes there is an externally-provided ``sphinx-build`` and requires at |
| 117 | least Python 2.6 to run. Because of this, it is no longer possible to |
| 118 | build a 3.4.1 or later installer on OS X 10.5 using the Apple-supplied |
| 119 | Python 2.5. |
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 120 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 121 | * It is safest to start each variant build with an empty source directory |
| 122 | populated with a fresh copy of the untarred source. |
| 123 | |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 124 | * It is recommended that you remove any existing installed version of the |
| 125 | Python being built:: |
| 126 | |
| 127 | sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n |
| 128 | |
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 129 | |
| 130 | The Recipe |
| 131 | ---------- |
| 132 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 133 | 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] | 134 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 135 | * Run ``build-installer.py``. Optionally you can pass a number of arguments |
| 136 | to specify locations of various files. Please see the top of |
| Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 137 | ``build-installer.py`` for its usage. |
| Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 138 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 139 | 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] | 140 | but also some 3th-party libraries that are needed for extensions. |
| 141 | |
| 142 | * When done the script will tell you where the DMG image is (by default |
| 143 | somewhere in ``/tmp/_py``). |
| 144 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 145 | Building other universal installers |
| 146 | ................................... |
| Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 147 | |
| 148 | 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] | 149 | OS X 10.5 Leopard or later:: |
| Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 150 | |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 151 | /usr/bin/python /build-installer.py \ |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 152 | --dep-target=10.5 |
| 153 | --universal-archs=all |
| 154 | --sdk-path=/Developer/SDKs/MacOSX10.5.sdk |
| Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 155 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 156 | This requires that the deployment target is 10.5, and hence |
| 157 | also that you are building on at least OS X 10.5. 4-way includes |
| 158 | ``i386``, ``x86_64``, ``ppc``, and ``ppc64`` (G5). ``ppc64`` executable |
| 159 | variants can only be run on G5 machines running 10.5. Note that, |
| 160 | while OS X 10.6 is only supported on Intel-based machines, it is possible |
| 161 | to run ``ppc`` (32-bit) executables unmodified thanks to the Rosetta ppc |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 162 | emulation in OS X 10.5 and 10.6. The 4-way installer variant must be |
| 163 | built with Xcode 3. It is not regularly built or tested. |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 164 | |
| 165 | Other ``--universal-archs`` options are ``64-bit`` (``x86_64``, ``ppc64``), |
| 166 | and ``3-way`` (``ppc``, ``i386``, ``x86_64``). None of these options |
| 167 | are regularly exercised; use at your own risk. |
| 168 | |
| Ronald Oussoren | 1943f86 | 2009-03-30 19:39:14 +0000 | [diff] [blame] | 169 | |
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 170 | Testing |
| 171 | ------- |
| 172 | |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 173 | Ideally, the resulting binaries should be installed and the test suite run |
| 174 | on all supported OS X releases and architectures. As a practical matter, |
| 175 | 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] | 176 | 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] | 177 | 10.9, 10.8, 10.7, 10.6, or 10.5. Variant 2 should be run on 10.9, 10.8, |
| 178 | 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] | 179 | |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 180 | /usr/local/bin/pythonn.n -m test -w -u all,-largefile |
| 181 | /usr/local/bin/pythonn.n-32 -m test -w -u all |
| Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 182 | |
| 183 | Certain tests will be skipped and some cause the interpreter to fail |
| 184 | which will likely generate ``Python quit unexpectedly`` alert messages |
| Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 185 | to be generated at several points during a test run. These are normal |
| 186 | during testing and can be ignored. |
| 187 | |
| 188 | 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] | 189 | 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] | 190 | It should also be tested from the command line:: |
| 191 | |
| 192 | /usr/local/bin/idlen.n |
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 193 | |