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