Skip to content

Commit 4ae38ba

Browse files
authored
Update build docs for macOS (GH-16844)
1 parent dedb99a commit 4ae38ba

File tree

3 files changed

+85
-90
lines changed

3 files changed

+85
-90
lines changed
File renamed without changes.

Mac/README renamed to Mac/README.rst

Lines changed: 71 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
=========================
2-
Python on Mac OS X README
3-
=========================
1+
======================
2+
Python on macOS README
3+
======================
44

55
:Authors:
66
Jack Jansen (2004-07),
77
Ronald Oussoren (2010-04),
8-
Ned Deily (2014-05)
8+
Ned Deily (2012-06)
99

10-
:Version: 2.7.15
11-
12-
This document provides a quick overview of some Mac OS X specific features in
10+
This document provides a quick overview of some macOS specific features in
1311
the Python distribution.
1412

15-
OS X specific arguments to configure
16-
====================================
13+
macOS specific arguments to configure
14+
=====================================
1715

1816
* ``--enable-framework[=DIR]``
1917

2018
If this argument is specified the build will create a Python.framework rather
2119
than a traditional Unix install. See the section
22-
_`Building and using a framework-based Python on Mac OS X` for more
20+
_`Building and using a framework-based Python on macOS` for more
2321
information on frameworks.
2422

2523
If the optional directory argument is specified the framework is installed
@@ -43,41 +41,51 @@ OS X specific arguments to configure
4341
Create a universal binary build of Python. This can be used with both
4442
regular and framework builds.
4543

46-
The optional argument specifies which OS X SDK should be used to perform the
47-
build. If xcodebuild is available and configured, this defaults to
48-
the Xcode default MacOS X SDK, otherwise ``/Developer/SDKs/MacOSX.10.4u.sdk``
49-
if available or ``/`` if not. When building on OS X 10.5 or later, you can
50-
specify ``/`` to use the installed system headers rather than an SDK. As of
51-
OS X 10.9, you should install the optional system headers from the Command
52-
Line Tools component using ``xcode-select``::
53-
54-
$ sudo xcode-select --install
55-
56-
See the section _`Building and using a universal binary of Python on Mac OS X`
57-
for more information.
44+
The optional argument specifies which macOS SDK should be used to perform the
45+
build. In most cases on current systems, you do not need to specify PATH or
46+
you can just use ``/``; the default MacOSX SDK for the active Xcode or Command
47+
Line Tools developer directory will be used. See the macOS ``xcrun`` man page
48+
for more information. Current versions of macOS and Xcode no longer install
49+
system header files in their traditional locations, like ``/usr/include`` and
50+
``/System/Library/Frameworks``; instead they are found within a MacOSX SDK.
51+
The Apple-supplied build tools handle this transparently and current
52+
versiona of Python now handle this as well. So it is no longer necessary,
53+
and since macOS 10.14, no longer possible to force the installation of system
54+
headers with ``xcode-select``.
5855

5956
* ``--with-universal-archs=VALUE``
6057

6158
Specify the kind of universal binary that should be created. This option is
6259
only valid when ``--enable-universalsdk`` is specified. The default is
63-
``32-bit`` if a building with a SDK that supports PPC, otherwise defaults
64-
to ``intel``.
60+
``32-bit`` if building with a SDK that supports PPC, otherwise defaults
61+
to ``intel``. Note that ``intel`` means a universal build of both 32-bit
62+
and 64-bit binaries and that may not be what you want; for example,
63+
as of macOS 10.15 Catalina, 32-bit execution is no longer supported by
64+
the operating system. Thus it is best to either explicitly specify
65+
values for ``--with-universal-archs``:
66+
67+
``--enable-universalsdk --with-universal-archs=intel-64``
6568

69+
or avoid using either.
6670

67-
Building and using a universal binary of Python on Mac OS X
68-
===========================================================
71+
72+
Building and using a universal binary of Python on macOS
73+
========================================================
6974

7075
1. What is a universal binary
7176
-----------------------------
7277

7378
A universal binary build of Python contains object code for more than one
74-
CPU architecture. A universal OS X executable file or library combines the
79+
CPU architecture. A universal macOS executable file or library combines the
7580
architecture-specific code into one file and can therefore run at native
7681
speed on all supported architectures. Universal files were introduced in
77-
OS X 10.4 to add support for Intel-based Macs to the existing PowerPC (PPC)
78-
machines. In OS X 10.5 support was extended to 64-bit Intel and 64-bit PPC
82+
macOS 10.4 to add support for Intel-based Macs to the existing PowerPC (PPC)
83+
machines. In macOS 10.5 support was extended to 64-bit Intel and 64-bit PPC
7984
architectures. It is possible to build Python with various combinations
80-
of architectures depending on the build tools and OS X version in use.
85+
of architectures depending on the build tools and macOS version in use.
86+
Note that PPC support was removed in macOS 10.7 and 32-bit Intel support
87+
was removed in macOS 10.15. So currently as of macOS 10.15, macOS only
88+
supports one execution architecture, 64-bit Intel (``x86_64``).
8189

8290
2. How do I build a universal binary
8391
------------------------------------
@@ -90,14 +98,14 @@ flag to configure::
9098
$ make install
9199

92100
This flag can be used with a framework build of python, but also with a classic
93-
unix build. Universal builds were first supported with OS X 10.4 with Xcode 2.1
94-
and the 10.4u SDK. Starting with Xcode 3 and OS X 10.5, more configurations are
101+
unix build. Universal builds were first supported with macOS 10.4 with Xcode 2.1
102+
and the 10.4u SDK. Starting with Xcode 3 and macOS 10.5, more configurations are
95103
available.
96104

97105
In general, universal builds depend on specific features provided by the
98106
Apple-supplied compilers and other build tools included in Apple's Xcode
99-
development tools. You should install Xcode and the command line tools
100-
component appropriate for the OS X release you are running on. See the
107+
development tools. You should install Xcode or the command line tools
108+
component appropriate for the macOS release you are running on. See the
101109
Python Developer's Guide (https://devguide.python.org/setup/)
102110
for more information.
103111

@@ -127,28 +135,29 @@ values are available:
127135
* ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
128136

129137
To build a universal binary that includes a 64-bit architecture, you must build
130-
on a system running OS X 10.5 or later. The ``all`` and ``64-bit`` flavors can
138+
on a system running macOS 10.5 or later. The ``all`` and ``64-bit`` flavors can
131139
only be built with a 10.5 SDK because ``ppc64`` support was only included with
132-
OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X
133-
10.6, it was removed in Xcode 4, versions of which were released on OS X 10.6
134-
and which is the standard for OS X 10.7. To summarize, the
140+
macOS 10.5. Although legacy ``ppc`` support was included with Xcode 3 on macOS
141+
10.6, it was removed in Xcode 4, versions of which were released on macOS 10.6
142+
and which is the standard for macOS 10.7. To summarize, the
135143
following combinations of SDKs and universal-archs flavors are available:
136144

137145
* 10.4u SDK with Xcode 2 supports ``32-bit`` only
138146

139147
* 10.5 SDK with Xcode 3.1.x supports all flavors
140148

141-
* 10.6 SDK with Xcode 3.2.x supports ``intel``, ``3-way``, and ``32-bit``
149+
* 10.6 SDK with Xcode 3.2.x supports ``intel``, ``intel-32``,
150+
``intel-64``, ``3-way``, and ``32-bit``
142151

143-
* 10.6 SDK with Xcode 4 supports ``intel`` only
152+
* 10.6 SDK with Xcode 4 supports ``intel``, ``intel-32``, and ``intel-64``
144153

145-
* 10.7 and 10.8 SDKs with Xcode 4 support ``intel`` only
154+
* 10.7 through 10.14 SDKs support ``intel``, ``intel-32``, and ``intel-64``
146155

147-
* 10.8 and 10.9 SDKs with Xcode 5 support ``intel`` only
156+
* 10.15 and later SDKs support ``intel-64`` only
148157

149158
The makefile for a framework build will also install ``python2.7-32``
150159
binaries when the universal architecture includes at least one 32-bit
151-
architecture (that is, for all flavors but ``64-bit``).
160+
architecture (that is, for all flavors but ``64-bit`` and ``intel-64``).
152161

153162
Running a specific architecture
154163
...............................
@@ -161,39 +170,34 @@ Or to explicitly run in 32-bit mode, regardless of the machine hardware::
161170

162171
$ arch -i386 -ppc python
163172

164-
NOTE: When you're using a framework install of Python this requires at least
165-
Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
166-
wrapper tools that execute the real interpreter without ensuring that the
167-
real interpreter runs with the same architecture.
168-
169173
Using ``arch`` is not a perfect solution as the selected architecture will
170174
not automatically carry through to subprocesses launched by programs and tests
171175
under that Python. If you want to ensure that Python interpreters launched in
172176
subprocesses also run in 32-bit-mode if the main interpreter does, use
173177
a ``python2.7-32`` binary and use the value of ``sys.executable`` as the
174178
``subprocess`` ``Popen`` executable value.
175179

176-
Building and using a framework-based Python on Mac OS X.
177-
========================================================
180+
Building and using a framework-based Python on macOS
181+
====================================================
178182

179183

180184
1. Why would I want a framework Python instead of a normal static Python?
181185
--------------------------------------------------------------------------
182186

183187
The main reason is because you want to create GUI programs in Python. With the
184188
exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
185-
from a Mac OS X application bundle (".app").
189+
from a macOS application bundle (".app").
186190

187191
While it is technically possible to create a .app without using frameworks you
188192
will have to do the work yourself if you really want this.
189193

190194
A second reason for using frameworks is that they put Python-related items in
191195
only two places: "/Library/Framework/Python.framework" and
192-
"/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.4",
196+
"/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.8",
193197
"2.7", etc. This simplifies matters for users installing
194198
Python from a binary distribution if they want to get rid of it again. Moreover,
195-
due to the way frameworks work, a user without admin privileges can install a
196-
binary distribution in his or her home directory without recompilation.
199+
due to the way frameworks work, usera without admin privileges can install a
200+
binary distribution in their home directory without recompilation.
197201

198202
2. How does a framework Python differ from a normal static Python?
199203
------------------------------------------------------------------
@@ -207,12 +211,12 @@ Versions/Current and you will see the familiar bin and lib directories.
207211
3. Do I need extra packages?
208212
----------------------------
209213

210-
Yes, probably. If you want Tkinter support you need to get the OS X AquaTk
211-
distribution, this is installed by default on Mac OS X 10.4 or later. Be
212-
aware, though, that the Cocoa-based AquaTk's supplied starting with OS X
214+
Yes, probably. If you want Tkinter support you need to get the macOS AquaTk
215+
distribution, this is installed by default on macOS 10.4 or later. Be
216+
aware, though, that the Cocoa-based AquaTk's supplied starting with macOS
213217
10.6 have proven to be unstable. If possible, you should consider
214-
installing a newer version before building on OS X 10.6 or later, such as
215-
the ActiveTcl 8.5. See http://www.python.org/download/mac/tcltk/. If you
218+
installing a newer version before building on macOS 10.6 or later, such as
219+
the ActiveTcl 8.6. See http://www.python.org/download/mac/tcltk/. If you
216220
are building with an SDK, ensure that the newer Tcl and Tk frameworks are
217221
seen in the SDK's ``Library/Frameworks`` directory; you may need to
218222
manually create symlinks to their installed location, ``/Library/Frameworks``.
@@ -223,7 +227,7 @@ If you want Cocoa you need to get PyObjC.
223227
-------------------------------------
224228

225229
This directory contains a Makefile that will create a couple of python-related
226-
applications (full-blown OS X .app applications, that is) in
230+
applications (full-blown macOS .app applications, that is) in
227231
"/Applications/Python <VERSION>", and a hidden helper application Python.app
228232
inside the Python.framework, and unix tools including "python" into
229233
/usr/local/bin. In addition it has a target "installmacsubtree" that installs
@@ -291,26 +295,25 @@ How do I create a binary distribution?
291295
Download and unpack the source release from http://www.python.org/download/.
292296
Go to the directory ``Mac/BuildScript``. There you will find a script
293297
``build-installer.py`` that does all the work. This will download and build
294-
a number of 3rd-party libaries, configures and builds a framework Python,
298+
a number of 3rd-party libraries, configures and builds a framework Python,
295299
installs it, creates the installer package files and then packs this in a
296300
DMG image. The script also builds an HTML copy of the current Python
297301
documentation set for this release for inclusion in the framework. The
298302
installer package will create links to the documentation for use by IDLE,
299303
pydoc, shell users, and Finder user.
300304

301305
The script will build a universal binary so you'll therefore have to run this
302-
script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
306+
script on macOS 10.4 or later and with Xcode 2.1 or later installed.
303307
However, the Python build process itself has several build dependencies not
304-
available out of the box with OS X 10.4 so you may have to install
305-
additional software beyond what is provided with Xcode 2. OS X 10.5
306-
provides a recent enough system Python (in ``/usr/bin``) to build
307-
the Python documentation set. It should be possible to use SDKs and/or older
308+
available out of the box with macOS 10.4 so you may have to install
309+
additional software beyond what is provided with Xcode 2.
310+
It should be possible to use SDKs and/or older
308311
versions of Xcode to build installers that are compatible with older systems
309312
on a newer system but this may not be completely foolproof so the resulting
310313
executables, shared libraries, and ``.so`` bundles should be carefully
311314
examined and tested on all supported systems for proper dynamic linking
312315
dependencies. It is safest to build the distribution on a system running the
313-
minimum OS X version supported.
316+
minimum macOS version supported.
314317

315318
All of this is normally done completely isolated in /tmp/_py, so it does not
316319
use your normal build directory nor does it install into /.
@@ -344,7 +347,7 @@ Uninstalling a framework install, including the binary installer
344347

345348
Uninstalling a framework can be done by manually removing all bits that got installed.
346349
That's true for both installations from source and installations using the binary installer.
347-
OS X does not provide a central uninstaller.
350+
macOS does not provide a central uninstaller.
348351

349352
The main bit of a framework install is the framework itself, installed in
350353
``/Library/Frameworks/Python.framework``. This can contain multiple versions

README

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -582,19 +582,30 @@ Reliant UNIX: The thread support does not compile on Reliant UNIX, and
582582
platform as well. This should be resolved in time for a
583583
future release.
584584

585-
MacOSX: The tests will crash on both 10.1 and 10.2 with SEGV in
585+
macOS: Building a complete Python installation requires the use of various
586+
additional third-party libraries, depending on your build platform and
587+
configure options. Not all standard library modules are buildable or
588+
useable on all platforms. Refer to the "Install Dependencies" section
589+
section of the "Developer Guide" for current detailed information on
590+
dependencies for macOS:
591+
https://devguide.python.org/setup/#install-dependencies
592+
593+
On macOS, there are additional configure and build options related
594+
to macOS framework and universal builds. Refer to Mac/README.rst.
595+
596+
The tests will crash on both 10.1 and 10.2 with SEGV in
586597
test_re and test_sre due to the small default stack size. If
587598
you set the stack size to 2048 before doing a "make test" the
588599
failure can be avoided. If you're using the tcsh or csh shells,
589600
use "limit stacksize 2048" and for the bash shell (the default
590-
as of OSX 10.3), use "ulimit -s 2048".
601+
as of macOS 10.3), use "ulimit -s 2048".
591602

592603
On naked Darwin you may want to add the configure option
593604
"--disable-toolbox-glue" to disable the glue code for the Carbon
594605
interface modules. The modules themselves are currently only built
595606
if you add the --enable-framework option, see below.
596607

597-
On a clean OSX /usr/local does not exist. Do a
608+
On a clean macOS /usr/local does not exist. Do a
598609
"sudo mkdir -m 775 /usr/local"
599610
before you do a make install. It is probably not a good idea to
600611
do "sudo make install" which installs everything as superuser,
@@ -605,20 +616,6 @@ MacOSX: The tests will crash on both 10.1 and 10.2 with SEGV in
605616
to install additional unix software. Disabling fink (remove all
606617
references to /sw from your .profile or .login) should solve this.
607618

608-
You may want to try the configure option "--enable-framework"
609-
which installs Python as a framework. The location can be set
610-
as argument to the --enable-framework option (default
611-
/Library/Frameworks). A framework install is probably needed if you
612-
want to use any Aqua-based GUI toolkit (whether Tkinter, wxPython,
613-
Carbon, Cocoa or anything else).
614-
615-
You may also want to try the configure option "--enable-universalsdk"
616-
which builds Python as a universal binary with support for the
617-
i386 and PPC architetures. This requires Xcode 2.1 or later to build.
618-
619-
See Mac/README for more information on framework and
620-
universal builds.
621-
622619
Cygwin: With recent (relative to the time of writing, 2001-12-19)
623620
Cygwin installations, there are problems with the interaction
624621
of dynamic linking and fork(). This manifests itself in build
@@ -949,11 +946,6 @@ Emacs found in Misc/python-mode.el. (But then again, more recent
949946
versions of Emacs may already have it.) Follow the instructions that
950947
came with Emacs for installation of site-specific files.
951948

952-
On Mac OS X, if you have configured Python with --enable-framework, you
953-
should use "make frameworkinstall" to do the installation. Note that this
954-
installs the Python executable in a place that is not normally on your
955-
PATH, you may want to set up a symlink in /usr/local/bin.
956-
957949

958950
Installing multiple versions
959951
----------------------------

0 commit comments

Comments
 (0)