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. |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 10 | The installer package built on the dmg is a macOS bundle format installer |
| 11 | package. This format is deprecated and is no longer supported by modern |
| 12 | macOS systems; it is usable on macOS 10.6 and earlier systems. |
| 13 | To be usable on newer versions of macOS, the bits in the bundle package |
| 14 | must be assembled in a macOS flat installer package, using current |
| 15 | versions of the pkgbuild and productbuild utilities. To pass macoS |
| 16 | Gatekeeper download quarantine, the final package must be signed |
| 17 | with a valid Apple Developer ID certificate using productsign. |
| 18 | Starting with macOS 10.15 Catalina, Gatekeeper now also requires |
| 19 | that installer packages are submitted to and pass Apple's automated |
| 20 | notarization service using the altool command. To pass notarization, |
| 21 | the binaries included in the package must be built with at least |
| 22 | the macOS 10.9 SDK, mout now be signed with the codesign utility |
| 23 | and executables must opt in to the hardened run time option with |
| 24 | any necessary entitlements. Details of these processes are |
| 25 | available in the on-line Apple Developer Documentation and man pages. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 26 | |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 27 | As of 3.8.0 and 3.7.7, PSF practice is to build one installer variants |
| 28 | for each release. Note that as of this writing, no Pythons support |
| 29 | building on a newer version of macOS that will run on older versions |
| 30 | by setting MACOSX_DEPLOYMENT_TARGET. This is because the various |
| 31 | Python C modules do not yet support runtime testing of macOS |
| 32 | feature availability (for example, by using macOS AvailabilityMacros.h |
| 33 | and weak-linking). To build a Python that is to be used on a |
| 34 | range of macOS releases, always build on the oldest release to be |
| 35 | supported; the necessary shared libraries for that release will |
| 36 | normally also be available on later systems, with the occasional |
| 37 | exception such as the removal of 32-bit libraries in macOS 10.15. |
Thomas Wouters | 477c8d5 | 2006-05-27 19:21:47 +0000 | [diff] [blame] | 38 | |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 39 | build-installer requires Apple Developer tools, either from the |
| 40 | Command Line Tools package or from a full Xcode installation. |
| 41 | You should use the most recent version of either for the operating |
| 42 | system version in use. (One notable exception: on macOS 10.6, |
| 43 | Snow Leopard, use Xcode 3, not Xcode 4 which was released later |
| 44 | in the 10.6 support cycle.) |
| 45 | |
| 46 | 1. 64-bit, x86_64, for OS X 10.9 (and later):: |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 47 | |
Ned Deily | 7e60f51 | 2014-04-07 12:10:21 -0700 | [diff] [blame] | 48 | /path/to/bootstrap/python2.7 build-installer.py \ |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 49 | --universal-archs=intel-64 \ |
| 50 | --dep-target=10.9 |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 51 | |
| 52 | - builds the following third-party libraries |
| 53 | |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 54 | * OpenSSL 1.1.1 |
| 55 | * Tcl/Tk 8.6 |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 56 | * NCurses |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 57 | * SQLite |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 58 | * XZ |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 59 | * libffi |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 60 | |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 61 | - uses system-supplied versions of third-party libraries |
| 62 | |
| 63 | * readline module links with Apple BSD editline (libedit) |
| 64 | * zlib |
| 65 | * bz2 |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 66 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 67 | - recommended build environment: |
Serhiy Storchaka | bfbfc8d | 2015-03-29 19:12:58 +0300 | [diff] [blame] | 68 | |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 69 | * Mac OS X 10.9.5 |
| 70 | * Xcode Command Line Tools 6.2 |
| 71 | * ``MacOSX10.9`` SDK |
| 72 | * ``MACOSX_DEPLOYMENT_TARGET=10.9`` |
| 73 | * Apple ``clang`` |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 74 | |
| 75 | |
| 76 | General Prerequisites |
| 77 | --------------------- |
| 78 | |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 79 | * No Fink (in ``/sw``) or MacPorts (in ``/opt/local``) or Homebrew or |
| 80 | other local libraries or utilities (in ``/usr/local``) as they could |
Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 81 | interfere with the build. |
| 82 | |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 83 | * It is safest to start each variant build with an empty source directory |
Ned Deily | 1931e64 | 2020-06-25 04:51:46 -0400 | [diff] [blame] | 84 | populated with a fresh copy of the untarred source or a source repo. |
Ned Deily | 2272670 | 2011-01-15 04:44:12 +0000 | [diff] [blame] | 85 | |
Ned Deily | 5c0b1ca | 2012-08-24 19:57:33 -0700 | [diff] [blame] | 86 | * It is recommended that you remove any existing installed version of the |
| 87 | Python being built:: |
| 88 | |
| 89 | sudo rm -rf /Library/Frameworks/Python.framework/Versions/n.n |
| 90 | |