10000 [3.12] Update "Using Python on a Mac" (GH-115024) (#115387) · python/cpython@a30bb08 · GitHub
[go: up one dir, main page]

Skip to content

Commit a30bb08

Browse files
[3.12] Update "Using Python on a Mac" (GH-115024) (#115387)
Update "Using Python on a Mac" (GH-115024) (cherry picked from commit 0a6e1a4) Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 1b36a8f commit a30bb08

File tree

2 files changed

+63
-46
lines changed

2 files changed

+63
-46
lines changed

Doc/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
import patchlevel
5959
version, release = patchlevel.get_version_info()
6060

61+
rst_epilog = f"""
62+
.. |python_version_literal| replace:: ``Python {version}``
63+
"""
64+
6165
# There are two options for replacing |today|: either, you set today to some
6266
# non-false value, then it is used:
6367
today = ''

Doc/using/mac.rst

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,46 @@ Using Python on a Mac
1010

1111
Python on a Mac running macOS is in principle very similar to Python on
1212
any other Unix platform, but there are a number of additional features such as
13-
the IDE and the Package Manager that are worth pointing out.
13+
the integrated development environment (IDE) and the Package Manager that are
14+
worth pointing out.
15+
1416

1517
.. _getting-osx:
18+
.. _getting-and-installing-macpython:
1619

17-
Getting and Installing MacPython
18-
================================
20+
Getting and Installing Python
21+
=============================
1922

2023
macOS used to come with Python 2.7 pre-installed between versions
2124
10.8 and `12.3 <https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes#Python>`_.
22-
You are invited to install the most recent version of Python 3 from the Python
23-
website (https://www.python.org). A current "universal binary" build of Python,
24-
which runs natively on the Mac's new Intel and legacy PPC CPU's, is available
25-
there.
25+
You are invited to install the most recent version of Python 3 from the `Python
26+
website <https://www.python.org/downloads/macos/>`__.
27+
A current "universal2 binary" build of Python, which runs natively on the Mac's
28+
new Apple Silicon and legacy Intel processors, is available there.
2629

2730
What you get after installing is a number of things:
2831

29-
* A :file:`Python 3.12` folder in your :file:`Applications` folder. In here
32+
* A |python_version_literal| folder in your :file:`Applications` folder. In here
3033
you find IDLE, the development environment that is a standard part of official
31-
Python distributions; and PythonLauncher, which handles double-clicking Python
34+
Python distributions; and :program:`Python Launcher`, which handles double-clicking Python
3235
scripts from the Finder.
3336

3437
* A framework :file:`/Library/Frameworks/Python.framework`, which includes the
3538
Python executable and libraries. The installer adds this location to your shell
36-
path. To uninstall MacPython, you can simply remove these three things. A
37-
symlink to the Python executable is placed in /usr/local/bin/.
38-
39-
The Apple-provided build of Python is installed in
40-
:file:`/System/Library/Frameworks/Python.framework` and :file:`/usr/bin/python`,
41-
respectively. You should never modify or delete these, as they are
42-
Apple-controlled and are used by Apple- or third-party software. Remember that
43-
if you choose to install a newer Python version from python.org, you will have
44-
two different but functional Python installations on your computer, so it will
45-
be important that your paths and usages are consistent with what you want to do.
46-
47-
IDLE includes a help menu that allows you to access Python documentation. If you
39+
path. To uninstall Python, you can remove these three things. A
40+
symlink to the Python executable is placed in :file:`/usr/local/bin/`.
41+
42+
.. note::
43+
44+
On macOS 10.8-12.3, the Apple-provided build of Python is installed in
45+
:file:`/System/Library/Frameworks/Python.framework` and :file:`/usr/bin/python`,
46+
respectively. You should never modify or delete these, as they are
47+
Apple-controlled and are used by Apple- or third-party software. Remember that
48+
if you choose to install a newer Python version from python.org, you will have
49+
two different but functional Python installations on your computer, so it will
50+
be important that your paths and usages are consistent with what you want to do.
51+
52+
IDLE includes a Help menu that allows you to access Python documentation. If you
4853
are completely new to Python you should start reading the tutorial introduction
4954
in that document.
5055

@@ -56,29 +61,29 @@ How to run a Python script
5661
--------------------------
5762

5863
Your best way to get started with Python on macOS is through the IDLE
59-
integrated development environment, see section :ref:`ide` and use the Help menu
64+
integrated development environment; see section :ref:`ide` and use the Help menu
6065
when the IDE is running.
6166

6267
If you want to run Python scripts from the Terminal window command line or from
6368
the Finder you first need an editor to create your script. macOS comes with a
64-
number of standard Unix command line editors, :program:`vim` and
65-
:program:`emacs` among them. If you want a more Mac-like editor,
66-
:program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see
67-
http://www.barebones.com/products/bbedit/index.html) are good choices, as is
68-
:program:`TextMate` (see https://macromates.com/). Other editors include
69-
:program:`Gvim` (https://macvim.org/macvim/) and :program:`Aquamacs`
70-
(http://aquamacs.org/).
69+
number of standard Unix command line editors, :program:`vim`
70+
:program:`nano` among them. If you want a more Mac-like editor,
71+
:program:`BBEdit` from Bare Bones Software (see
72+
https://www.barebones.com/products/bbedit/index.html) are good choices, as is
73+
:program:`TextMate` (see https://macromates.com). Other editors include
74+
:program:`MacVim` (https://macvim.org) and :program:`Aquamacs`
75+
(https://aquamacs.org).
7176

7277
To run your script from the Terminal window you must make sure that
7378
:file:`/usr/local/bin` is in your shell search path.
7479

7580
To run your script from the Finder you have two options:
7681

77-
* Drag it to :program:`PythonLauncher`
82+
* Drag it to :program:`Python Launcher`.
7883

79-
* Select :program:`PythonLauncher` as the default application to open your
80-
script (or any .py script) through the finder Info window and double-click it.
81-
:program:`PythonLauncher` has various preferences to control how your script is
84+
* Select :program:`Python Launcher` as the default application to open your
85+
script (or any ``.py`` script) through the finder Info window and double-click it.
86+
:program:`Python Launcher` has various preferences to control how your script is
8287
launched. Option-dragging allows you to change these for one invocation, or use
8388
its Preferences menu to change things globally.
8489

@@ -103,10 +108,11 @@ Python on macOS honors all standard Unix environment variables such as
103108
:envvar:`PYTHONPATH`, but setting these variables for programs started from the
104109
Finder is non-standard as the Finder does not read your :file:`.profile` or
105110
:file:`.cshrc` at startup. You need to create a file
106-
:file:`~/.MacOSX/environment.plist`. See Apple's Technical Document QA1067 for
107-
details.
111+
:file:`~/.MacOSX/environment.plist`. See Apple's
112+
`Technical Q&A QA1067 <https://developer.apple.com/library/archive/qa/qa1067/_index.html>`__
113+
for details.
108114

109-
For more information on installation Python packages in MacPython, see section
115+
For more information on installation Python packages, see section
110116
:ref:`mac-package-manager`.
111117

112118

@@ -115,9 +121,9 @@ For more information on installation Python packages in MacPython, see section
115121
The IDE
116122
=======
117123

118-
MacPython ships with the standard IDLE development environment. A good
124+
Python ships with the standard IDLE development environment. A good
119125
introduction to using IDLE can be found at
120-
http://www.hashcollision.org/hkn/python/idle_intro/index.html.
126+
https://www.hashcollision.org/hkn/python/idle_intro/index.html.
121127

122128

123129
.. _mac-package-manager:
@@ -130,8 +136,10 @@ This section has moved to the `Python Packaging User Guide`_.
130136
.. _Python Packaging User Guide: https://packaging.python.org/en/latest/tutorials/installing-packages/
131137

132138

133-
GUI Programming on the Mac
134-
==========================
139+
.. _gui-programming-on-the-mac:
140+
141+
GUI Programming
142+
===============
135143

136144
There are several options for building GUI applications on the Mac with Python.
137145

@@ -151,20 +159,25 @@ macOS. Packages and documentation are available from https://www.wxpython.org.
151159
macOS. More information can be found at
152160
https://riverbankcomputing.com/software/pyqt/intro.
153161

162+
*PySide* is another cross-platform Qt-based toolkit. More information at
163+
https://www.qt.io/qt-for-python.
164+
154165

155-
Distributing Python Applications on the Mac
156-
===========================================
166+
.. _distributing-python-applications-on-the-mac:
167+
168+
Distributing Python Applications
169+
================================
157170

158171
The standard tool for deploying standalone Python applications on the Mac is
159-
:program:`py2app`. More information on installing and using py2app can be found
160-
at https://pypi.org/project/py2app/.
172+
:program:`py2app`. More information on installing and using :program:`py2app`
173+
can be found at https://pypi.org/project/py2app/.
161174

162175

163176
Other Resources
164177
===============
165178

166-
The MacPython mailing list is an excellent support resource for Python users and
167-
developers on the Mac:
179+
The Pythonmac-SIG mailing list is an excellent support resource for Python users
180+
and developers on the Mac:
168181

169182
https://www.python.org/community/sigs/current/pythonmac-sig/
170183

0 commit comments

Comments
 (0)
0