1Building a Python Mac OS X distribution 2======================================= 3 4The ``build-install.py`` script creates Python distributions, including 5certain third-party libraries as necessary. It builds a complete 6framework-based Python out-of-tree, installs it in a funny place with 7$DESTROOT, massages that installation to remove .pyc files and such, creates 8an Installer package from the installation plus other files in ``resources`` 9and ``scripts`` and placed that on a ``.dmg`` disk image. 10The installer package built on the dmg is a macOS bundle format installer 11package. This format is deprecated and is no longer supported by modern 12macOS systems; it is usable on macOS 10.6 and earlier systems. 13To be usable on newer versions of macOS, the bits in the bundle package 14must be assembled in a macOS flat installer package, using current 15versions of the pkgbuild and productbuild utilities. To pass macoS 16Gatekeeper download quarantine, the final package must be signed 17with a valid Apple Developer ID certificate using productsign. 18Starting with macOS 10.15 Catalina, Gatekeeper now also requires 19that installer packages are submitted to and pass Apple's automated 20notarization service using the altool command. To pass notarization, 21the binaries included in the package must be built with at least 22the macOS 10.9 SDK, mout now be signed with the codesign utility 23and executables must opt in to the hardened run time option with 24any necessary entitlements. Details of these processes are 25available in the on-line Apple Developer Documentation and man pages. 26 27As of 3.8.0 and 3.7.7, PSF practice is to build one installer variants 28for each release. Note that as of this writing, no Pythons support 29building on a newer version of macOS that will run on older versions 30by setting MACOSX_DEPLOYMENT_TARGET. This is because the various 31Python C modules do not yet support runtime testing of macOS 32feature availability (for example, by using macOS AvailabilityMacros.h 33and weak-linking). To build a Python that is to be used on a 34range of macOS releases, always build on the oldest release to be 35supported; the necessary shared libraries for that release will 36normally also be available on later systems, with the occasional 37exception such as the removal of 32-bit libraries in macOS 10.15. 38 39build-installer requires Apple Developer tools, either from the 40Command Line Tools package or from a full Xcode installation. 41You should use the most recent version of either for the operating 42system version in use. (One notable exception: on macOS 10.6, 43Snow Leopard, use Xcode 3, not Xcode 4 which was released later 44in the 10.6 support cycle.) 45 461. 64-bit, x86_64, for OS X 10.9 (and later):: 47 48 /path/to/bootstrap/python2.7 build-installer.py \ 49 --universal-archs=intel-64 \ 50 --dep-target=10.9 51 52 - builds the following third-party libraries 53 54 * OpenSSL 1.1.1 55 * Tcl/Tk 8.6 56 * NCurses 57 * SQLite 58 * XZ 59 * libffi 60 61 - uses system-supplied versions of third-party libraries 62 63 * readline module links with Apple BSD editline (libedit) 64 * zlib 65 * bz2 66 67 - recommended build environment: 68 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`` 74 75 76General Prerequisites 77--------------------- 78 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 81 interfere with the build. 82 83* It is safest to start each variant build with an empty source directory 84 populated with a fresh copy of the untarred source or a source repo. 85 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 91