Skip to content

Commit d1e0568

Browse files
authored
[3.7] Update build docs for macOS (GH-16771) (GH-16774)
1 parent c60bed3 commit d1e0568

File tree

3 files changed

+90
-83
lines changed

3 files changed

+90
-83
lines changed
File renamed without changes.

Mac/README renamed to Mac/README.rst

Lines changed: 74 additions & 69 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),
88
Ned Deily (2012-06)
99

10-
:Version: 3.4.0
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``:
6566

67+
``--enable-universalsdk --with-universal-archs=intel-64``
6668

67-
Building and using a universal binary of Python on Mac OS X
68-
===========================================================
69+
or avoid using either.
70+
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

@@ -116,6 +124,8 @@ values are available:
116124

117125
* ``intel-32``: ``i386``
118126

127+
* ``intel-64``: ``x86_64``
128+
119129
* ``32-bit``: ``ppc``, ``i386``
120130

121131
* ``3-way``: ``i386``, ``x86_64``, ``ppc``
@@ -125,28 +135,29 @@ values are available:
125135
* ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
126136

127137
To build a universal binary that includes a 64-bit architecture, you must build
128-
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
129139
only be built with a 10.5 SDK because ``ppc64`` support was only included with
130-
OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X
131-
10.6, it was removed in Xcode 4, versions of which were released on OS X 10.6
132-
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
133143
following combinations of SDKs and universal-archs flavors are available:
134144

135145
* 10.4u SDK with Xcode 2 supports ``32-bit`` only
136146

137147
* 10.5 SDK with Xcode 3.1.x supports all flavors
138148

139-
* 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``
140151

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

143-
* 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``
144155

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

147-
The makefile for a framework build will also install ``python3.4-32``
158+
The makefile for a framework build will also install ``python3.x-32``
148159
binaries when the universal architecture includes at least one 32-bit
149-
architecture (that is, for all flavors but ``64-bit``).
160+
architecture (that is, for all flavors but ``64-bit`` and ``intel-64``).
150161

151162
Running a specific architecture
152163
...............................
@@ -159,39 +170,34 @@ Or to explicitly run in 32-bit mode, regardless of the machine hardware::
159170

160171
$ arch -i386 -ppc python
161172

162-
NOTE: When you're using a framework install of Python this requires at least
163-
Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
164-
wrapper tools that execute the real interpreter without ensuring that the
165-
real interpreter runs with the same architecture.
166-
167173
Using ``arch`` is not a perfect solution as the selected architecture will
168174
not automatically carry through to subprocesses launched by programs and tests
169175
under that Python. If you want to ensure that Python interpreters launched in
170176
subprocesses also run in 32-bit-mode if the main interpreter does, use
171-
a ``python3.4-32`` binary and use the value of ``sys.executable`` as the
177+
a ``python3.x-32`` binary and use the value of ``sys.executable`` as the
172178
``subprocess`` ``Popen`` executable value.
173179

174-
Building and using a framework-based Python on Mac OS X.
175-
========================================================
180+
Building and using a framework-based Python on macOS
181+
====================================================
176182

177183

178184
1. Why would I want a framework Python instead of a normal static Python?
179185
--------------------------------------------------------------------------
180186

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

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

188194
A second reason for using frameworks is that they put Python-related items in
189195
only two places: "/Library/Framework/Python.framework" and
190-
"/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.4",
196+
"/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.8",
191197
"2.7", etc. This simplifies matters for users installing
192198
Python from a binary distribution if they want to get rid of it again. Moreover,
193-
due to the way frameworks work, a user without admin privileges can install a
194-
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.
195201

196202
2. How does a framework Python differ from a normal static Python?
197203
------------------------------------------------------------------
@@ -205,12 +211,12 @@ Versions/Current and you will see the familiar bin and lib directories.
205211
3. Do I need extra packages?
206212
----------------------------
207213

208-
Yes, probably. If you want Tkinter support you need to get the OS X AquaTk
209-
distribution, this is installed by default on Mac OS X 10.4 or later. Be
210-
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
211217
10.6 have proven to be unstable. If possible, you should consider
212-
installing a newer version before building on OS X 10.6 or later, such as
213-
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
214220
are building with an SDK, ensure that the newer Tcl and Tk frameworks are
215221
seen in the SDK's ``Library/Frameworks`` directory; you may need to
216222
manually create symlinks to their installed location, ``/Library/Frameworks``.
@@ -221,7 +227,7 @@ If you want Cocoa you need to get PyObjC.
221227
-------------------------------------
222228

223229
This directory contains a Makefile that will create a couple of python-related
224-
applications (full-blown OS X .app applications, that is) in
230+
applications (full-blown macOS .app applications, that is) in
225231
"/Applications/Python <VERSION>", and a hidden helper application Python.app
226232
inside the Python.framework, and unix tools including "python" into
227233
/usr/local/bin. In addition it has a target "installmacsubtree" that installs
@@ -271,7 +277,7 @@ through Python Launcher's preferences dialog.
271277

272278
The program ``pythonx.x`` runs python scripts from the command line.
273279
Previously, various compatibility aliases were also installed, including
274-
``pythonwx.x`` which in early releases of Python on OS X was required to run
280+
``pythonwx.x`` which in early releases of Python on macOS was required to run
275281
GUI programs. As of 3.4.0, the ``pythonwx.x`` aliases are no longer installed.
276282

277283
How do I create a binary distribution?
@@ -288,18 +294,17 @@ installer package will create links to the documentation for use by IDLE,
288294
pydoc, shell users, and Finder user.
289295

290296
The script will build a universal binary so you'll therefore have to run this
291-
script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
297+
script on macOS 10.4 or later and with Xcode 2.1 or later installed.
292298
However, the Python build process itself has several build dependencies not
293-
available out of the box with OS X 10.4 so you may have to install
294-
additional software beyond what is provided with Xcode 2. OS X 10.5
295-
provides a recent enough system Python (in ``/usr/bin``) to build
296-
the Python documentation set. It should be possible to use SDKs and/or older
299+
available out of the box with macOS 10.4 so you may have to install
300+
additional software beyond what is provided with Xcode 2.
301+
It should be possible to use SDKs and/or older
297302
versions of Xcode to build installers that are compatible with older systems
298303
on a newer system but this may not be completely foolproof so the resulting
299304
executables, shared libraries, and ``.so`` bundles should be carefully
300305
examined and tested on all supported systems for proper dynamic linking
301306
dependencies. It is safest to build the distribution on a system running the
302-
minimum OS X version supported.
307+
minimum macOS version supported.
303308

304309
All of this is normally done completely isolated in /tmp/_py, so it does not
305310
use your normal build directory nor does it install into /.
@@ -333,7 +338,7 @@ Uninstalling a framework install, including the binary installer
333338

334339
Uninstalling a framework can be done by manually removing all bits that got installed.
335340
That's true for both installations from source and installations using the binary installer.
336-
OS X does not provide a central uninstaller.
341+
macOS does not provide a central uninstaller.
337342

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

README.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,23 @@ On Unix, Linux, BSD, macOS, and Cygwin::
5959
This will install Python as ``python3``.
6060

6161
You can pass many options to the configure script; run ``./configure --help``
62-
to find out more. On macOS and Cygwin, the executable is called ``python.exe``;
63-
elsewhere it's just ``python``.
62+
to find out more. On macOS case-insensitive file systems and on Cygwin,
63+
the executable is called ``python.exe``; elsewhere it's just ``python``.
6464

65-
If you are running on macOS with the latest updates installed, make sure to install
66-
openSSL or some other SSL software along with Homebrew or another package manager.
67-
If issues persist, see https://devguide.python.org/setup/#macos-and-os-x for more
68-
information.
65+
Building a complete Python installation requires the use of various
66+
additional third-party libraries, depending on your build platform and
67+
configure options. Not all standard library modules are buildable or
68+
useable on all platforms. Refer to the
69+
`Install dependencies <https://devguide.python.org/setup/#install-dependencies>`_
70+
section of the `Developer Guide`_ for current detailed information on
71+
dependencies for various Linux distributions and macOS.
6972

70-
On macOS, if you have configured Python with ``--enable-framework``, you
71-
should use ``make frameworkinstall`` to do the installation. Note that this
72-
installs the Python executable in a place that is not normally on your PATH,
73-
you may want to set up a symlink in ``/usr/local/bin``.
73+
On macOS, there are additional configure and build options related
74+
to macOS framework and universal builds. Refer to `Mac/README.rst
75+
<https://github.com/python/cpython/blob/3.7/Mac/README.rst>`_.
7476

7577
On Windows, see `PCbuild/readme.txt
76-
<https://github.com/python/cpython/blob/master/PCbuild/readme.txt>`_.
78+
<https://github.com/python/cpython/blob/3.7/PCbuild/readme.txt>`_.
7779

7880
If you wish, you can create a subdirectory and invoke configure from there.
7981
For example::
@@ -135,9 +137,9 @@ What's New
135137
We have a comprehensive overview of the changes in the `What's New in Python
136138
3.7 <https://docs.python.org/3.7/whatsnew/3.7.html>`_ document. For a more
137139
detailed change log, read `Misc/NEWS
138-
<https://github.com/python/cpython/blob/master/Misc/NEWS.d>`_, but a full
140+
<https://github.com/python/cpython/blob/3.7/Misc/NEWS.d>`_, but a full
139141
accounting of changes can only be gleaned from the `commit history
140-
<https://github.com/python/cpython/commits/master>`_.
142+
<https://github.com/python/cpython/commits/3.7>`_.
141143

142144
If you want to install multiple versions of Python see the section below
143145
entitled "Installing multiple versions".
@@ -155,7 +157,7 @@ is primarily for documentation authors, translators, and people with special
155157
formatting requirements.
156158

157159
For information about building Python's documentation, refer to `Doc/README.rst
158-
<https://github.com/python/cpython/blob/master/Doc/README.rst>`_.
160+
<https://github.com/python/cpython/blob/3.7/Doc/README.rst>`_.
159161

160162

161163
Converting From Python 2.x to 3.x

0 commit comments

Comments
 (0)