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