Skip to content

Commit ae5c457

Browse files
authored
gh-160425: Use parsed literals to keep version current in Windows docs (#160430)
1 parent b1e32ff commit ae5c457

2 files changed

Lines changed: 65 additions & 55 deletions

File tree

‎Doc/conf.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@
8686
.. |python_x_dot_y_literal| replace:: ``python{version}``
8787
.. |python_x_dot_y_t_literal| replace:: ``python{version}t``
8888
.. |python_x_dot_y_t_literal_config| replace:: ``python{version}t-config``
89+
.. |python_x_dot_y_exe_literal| replace:: ``python{version}.exe``
90+
.. |python_x_dot_y_t_exe_literal| replace:: ``python{version}t.exe``
91+
.. |python_xy_dll_literal| replace:: ``python{v.major}{v.minor}.dll``
92+
.. |py_v_x_dot_y_literal| replace:: ``py -V:{version}``
93+
.. |py_v_x_dot_y_t_literal| replace:: ``py -V:{version}t``
94+
.. |x_dot_y_literal| replace:: ``{version}``
95+
.. |x_dot_y_64_literal| replace:: ``{version}-64``
8996
.. |x_dot_y_b2_literal| replace:: ``{version}.0b2``
9097
.. |applications_python_version_literal| replace:: ``/Applications/Python {version}/``
9198
.. |usr_local_bin_python_x_dot_y_literal| replace:: ``/usr/local/bin/python{version}``

‎Doc/using/windows.rst‎

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ other tools you are using is generally a worthwhile benefit. Before committing
2323
to the process described here, we recommend investigating your existing tools to
2424
see if they can provide Python directly.
2525

26-
To obtain Python from the CPython team, use the Python Install Manager. This
26+
To obtain Python from the CPython team, use the Python install manager. This
2727
is a standalone tool that makes Python available as global commands on your
2828
Windows machine, integrates with the system, and supports updates over time. You
29-
can download the Python Install Manager from `python.org/downloads`_ or through
29+
can download the Python install manager from `python.org/downloads`_ or through
3030
the `Microsoft Store app`_.
3131

32-
Once you have installed the Python Install Manager, the global ``python``
32+
Once you have installed the Python install manager, the global ``python``
3333
command can be used from any terminal to launch your current latest version of
3434
Python. This version may change over time as you add or remove different
3535
versions, and the ``py list`` command will show which is current.
@@ -40,7 +40,7 @@ This provides isolation between projects, consistency over time, and ensures
4040
that additional commands added by packages are also available in your session.
4141
Create a virtual environment using ``python -m venv <env path>``.
4242

43-
If the ``python`` or ``py`` commands do not seem to be working, please see the
43+
If the ``python`` or ``py`` commands do not seem to be working, see the
4444
:ref:`Troubleshooting <pymanager-troubleshoot>` section below. There are
4545
sometimes additional manual steps required to configure your PC.
4646

@@ -76,7 +76,7 @@ To install through the Store, simply click "Install". After it has completed,
7676
open a terminal and type ``python`` to get started.
7777

7878
To install the file downloaded from python.org, either double-click and select
79-
"Install", or run ``Add-AppxPackage <path to MSIX>`` in Windows Powershell.
79+
"Install", or run ``Add-AppxPackage <path to MSIX>`` in Windows PowerShell.
8080

8181
After installation, the ``python``, ``py``, and ``pymanager`` commands should be
8282
available. If you have existing installations of Python, or you have modified
@@ -87,7 +87,7 @@ non-working commands.
8787
When you first install a runtime, you will likely be prompted to add a directory
8888
to your :envvar:`PATH`. This is optional, if you prefer to use the ``py``
8989
command, but is offered for those who prefer the full range of aliases (such
90-
as ``python3.14.exe``) to be available. The directory will be
90+
as |python_x_dot_y_exe_literal|) to be available. The directory will be
9191
:file:`%LocalAppData%\\Python\\bin` by default, but may be customized by an
9292
administrator. Click Start and search for "Edit environment variables for your
9393
account" for the system settings page to add the path.
@@ -101,7 +101,7 @@ manager does not uninstall any Python runtimes.
101101

102102
If you are not able to install an MSIX in your context, for example, you are
103103
using automated deployment software that does not support it, or are targeting
104-
Windows Server 2019, please see :ref:`pymanager-advancedinstall` below for more
104+
Windows Server 2019, see :ref:`pymanager-advancedinstall` below for more
105105
information.
106106

107107

@@ -158,9 +158,9 @@ version, potentially with the platform. For compatibility, the ``V:`` may be
158158
omitted in cases where the tag refers to an official release and starts with
159159
``3``.
160160

161-
.. code::
161+
.. parsed-literal::
162162
163-
$> py -V:3.14 ...
163+
$> py -V:|version| ...
164164
$> py -V:3-arm64 ...
165165
166166
Runtimes from other distributors may require the *company* to be included as
@@ -232,7 +232,7 @@ added in the form of one or more tags (with or without company specifier), and
232232
each may include a ``<``, ``<=``, ``>=`` or ``>`` prefix to restrict to a range.
233233

234234
A range of formats are supported, and can be passed as the ``--format=<FMT>`` or
235-
``-f <FMT>`` option. Formats include ``table`` (a user friendly table view),
235+
``-f <FMT>`` option. Formats include ``table`` (a user-friendly table view),
236236
``csv`` (comma-separated table), ``json`` (a single JSON blob), ``jsonl`` (one
237237
JSON blob per result), ``exe`` (just the executable path), ``prefix`` (just the
238238
prefix path).
@@ -252,13 +252,13 @@ source. Passing either of these options will search the online index for
252252
runtimes that can be installed. The result shown by ``py list --online --one
253253
<TAG>`` will match the runtime that would be installed by ``py install <TAG>``.
254254

255-
.. code::
255+
.. parsed-literal::
256256
257-
$> py list --online 3.14
257+
$> py list --online |version|
258258
259259
For compatibility with the old launcher, the ``--list``, ``--list-paths``,
260-
``-0`` and ``-0p`` commands (e.g. ``py -0p``) are retained. They do not allow
261-
additional options, and will produce legacy formatted output.
260+
``-0`` and ``-0p`` commands (for example, ``py -0p``) are retained. They do not allow
261+
additional options, and will produce legacy-formatted output.
262262

263263

264264
Installing runtimes
@@ -289,9 +289,11 @@ To see the available runtime variants, run::
289289
py list --online
290290

291291
To install a specific variant, include it in the tag passed to
292-
``py install``::
292+
``py install``:
293+
294+
.. parsed-literal::
293295
294-
py install PythonTest\3.14
296+
py install PythonTest\\\ |version|
295297
296298
The ``--source=<URL>`` option allows overriding the online index that is used to
297299
obtain runtimes. This may be used with an offline index, as shown in
@@ -312,7 +314,7 @@ installs.
312314

313315
Passing ``--refresh`` will update all registrations for installed runtimes. This
314316
will recreate Start menu shortcuts, registry keys, and global aliases (such as
315-
``python3.14.exe`` or for any installed scripts). These are automatically
317+
|python_x_dot_y_exe_literal| or for any installed scripts). These are automatically
316318
refreshed on installation of any runtime, but may need to be manually refreshed
317319
after installing packages.
318320

@@ -456,10 +458,10 @@ customization.
456458
* - ``default_platform``
457459
- ``PYTHON_MANAGER_DEFAULT_PLATFORM``
458460
- The preferred default platform to launch or install.
459-
This is treated as a suffix to the specified tag, such that ``py -V:3.14``
460-
would prefer an install for ``3.14-64`` if it exists
461+
This is treated as a suffix to the specified tag, such that |py_v_x_dot_y_literal|
462+
would prefer an install for |x_dot_y_64_literal| if it exists
461463
(and ``default_platform`` is ``-64``),
462-
but will use ``3.14`` if no tagged install exists.
464+
but will use |x_dot_y_literal| if no tagged install exists.
463465

464466
* - ``logs_dir``
465467
- ``PYTHON_MANAGER_LOGS``
@@ -531,7 +533,7 @@ customization.
531533

532534
* - ``global_dir``
533535
- (none)
534-
- Specify the directory where global commands (such as ``python3.14.exe``
536+
- Specify the directory where global commands (such as |python_x_dot_y_exe_literal|
535537
and ``pip.exe``) are stored.
536538
This directory should be added to your :envvar:`PATH` to make the
537539
commands available from your terminal.
@@ -553,7 +555,7 @@ Shebang lines
553555
-------------
554556

555557
If the first line of a script file starts with ``#!``, it is known as a
556-
"shebang" line. Linux and other Unix like operating systems have native
558+
"shebang" line. Linux and other Unix-like operating systems have native
557559
support for such lines and they are commonly used on such systems to indicate
558560
how a script should be executed. The ``python`` and ``py`` commands allow the
559561
same facilities to be used with Python scripts on Windows.
@@ -597,7 +599,7 @@ prefers launching known Python commands. A warning may be displayed when
597599
searching for arbitrary executables, and this search may be disabled by the
598600
``shebang_can_run_anything`` configuration option.
599601

600-
Shebang lines that do not match any of patterns are treated as *Windows*
602+
Shebang lines that do not match any of the patterns are treated as *Windows*
601603
executable paths that are absolute or relative to the directory containing the
602604
script file. This is a convenience for Windows-only scripts, such as those
603605
generated by an installer, since the behavior is not compatible with Unix-style
@@ -730,7 +732,7 @@ deployment tool.
730732

731733
Regardless of the install method, users will still need to install their own
732734
copies of Python itself, as there is no way to trigger those installs without
733-
being a logged in user. When using the MSIX, the latest version of Python will
735+
being a logged-in user. When using the MSIX, the latest version of Python will
734736
be available for all users to install without network access.
735737

736738
Note that the MSIX downloadable from the Store and from the Python website are
@@ -806,12 +808,13 @@ directory containing the configuration file that specified them.
806808
- Path or URL to an index to consult when the main index cannot be accessed.
807809

808810
* - ``install.enable_shortcut_kinds``
809-
- Comma-separated list of shortcut kinds to allow (e.g. ``"pep514,start"``).
811+
- Comma-separated list of shortcut kinds to allow
812+
(for example, ``"pep514,start"``).
810813
Enabled shortcuts may still be disabled by ``disable_shortcut_kinds``.
811814

812815
* - ``install.disable_shortcut_kinds``
813816
- Comma-separated list of shortcut kinds to exclude
814-
(e.g. ``"pep514,start"``).
817+
(for example, ``"pep514,start"``).
815818
Disabled shortcuts are not reactivated by ``enable_shortcut_kinds``.
816819

817820
* - ``install.hard_link_entrypoints``
@@ -858,16 +861,16 @@ Installing free-threaded binaries
858861
Pre-built distributions of the free-threaded build are available
859862
by installing tags with the ``t`` suffix.
860863

861-
.. code::
864+
.. parsed-literal::
862865
863-
$> py install 3.14t
864-
$> py install 3.14t-arm64
865-
$> py install 3.14t-32
866+
$> py install |version|\ t
867+
$> py install |version|\ t-arm64
868+
$> py install |version|\ t-32
866869
867870
This will install and register as normal. If you have no other runtimes
868871
installed, then ``python`` will launch this one. Otherwise, you will need to use
869-
``py -V:3.14t ...`` or, if you have added the global aliases directory to your
870-
:envvar:`PATH` environment variable, the ``python3.14t.exe`` commands.
872+
|py_v_x_dot_y_t_literal| or, if you have added the global aliases directory to your
873+
:envvar:`PATH` environment variable, the |python_x_dot_y_t_exe_literal| commands.
871874

872875

873876
.. _pymanager-index-signatures:
@@ -895,7 +898,7 @@ As well as requiring a valid signature, the ``required_root_subject`` and
895898
signatures based on the certificate Subject fields. Any attribute specified in
896899
the configuration must match the attribute in the certificate (additional
897900
attributes in the certificate are ignored). Typical attributes are ``CN=`` for
898-
the common name, ``O=`` for the organizational unit, and ``C=`` for the
901+
the common name, ``O=`` for the organization, and ``C=`` for the
899902
publisher's country.
900903

901904
Finally, the ``required_publisher_eku`` setting allows requiring that a specific
@@ -1000,8 +1003,8 @@ one set of credentials will be used for both types of proxy.
10001003
Troubleshooting
10011004
---------------
10021005

1003-
If your Python install manager does not seem to be working correctly, please
1004-
work through these tests and fixes to see if it helps. If not, please report an
1006+
If your Python install manager does not seem to be working correctly,
1007+
work through these tests and fixes to see if it helps. If not, report an
10051008
issue at `our bug tracker <https://github.com/python/pymanager/issues>`_,
10061009
including any relevant log files (written to your :file:`%TEMP%` directory by
10071010
default).
@@ -1152,16 +1155,16 @@ directly accessed by end-users.
11521155
To install an embedded distribution, we recommend using ``py install`` with the
11531156
``--target`` option:
11541157

1155-
.. code::
1158+
.. parsed-literal::
11561159
1157-
$> py install 3.14-embed --target=<directory>
1160+
$> py install |version|-embed --target=<directory>
11581161
11591162
When extracted, the embedded distribution is (almost) fully isolated from the
11601163
user's system, including environment variables, system registry settings, and
11611164
installed packages. The standard library is included as pre-compiled and
1162-
optimized ``.pyc`` files in a ZIP, and ``python3.dll``, ``python313.dll``,
1163-
``python.exe`` and ``pythonw.exe`` are all provided. Tcl/tk (including all
1164-
dependents, such as Idle), pip and the Python documentation are not included.
1165+
optimized ``.pyc`` files in a ZIP, and ``python3.dll``, |python_xy_dll_literal|,
1166+
``python.exe`` and ``pythonw.exe`` are all provided. Tcl/Tk (including all
1167+
dependents, such as IDLE), pip and the Python documentation are not included.
11651168

11661169
A default ``._pth`` file is included, which further restricts the default search
11671170
paths (as described below in :ref:`windows_finding_modules`). This file is
@@ -1216,7 +1219,7 @@ installation is sufficient to provide a loadable Python interpreter.
12161219

12171220
As with the application use, packages can be installed to any location as there
12181221
is an opportunity to specify search paths before initializing the interpreter.
1219-
Otherwise, there is no fundamental differences between using the embedded
1222+
Otherwise, there are no fundamental differences between using the embedded
12201223
distribution and a regular installation.
12211224

12221225

@@ -1267,7 +1270,7 @@ delete the package directory manually and install it again. Many CI systems
12671270
will do this automatically if they do not preserve files between builds.
12681271

12691272
Alongside the ``tools`` directory is a ``build\native`` directory. This
1270-
contains a MSBuild properties file ``python.props`` that can be used in a
1273+
contains an MSBuild properties file ``python.props`` that can be used in a
12711274
C++ project to reference the Python install. Including the settings will
12721275
automatically use the headers and import libraries in your build.
12731276

@@ -1276,7 +1279,7 @@ The package information pages on nuget.org are
12761279
for the 64-bit version, `www.nuget.org/packages/pythonx86
12771280
<https://www.nuget.org/packages/pythonx86>`_ for the 32-bit version, and
12781281
`www.nuget.org/packages/pythonarm64
1279-
<https://www.nuget.org/packages/pythonarm64>`_ for the ARM64 version
1282+
<https://www.nuget.org/packages/pythonarm64>`_ for the ARM64 version.
12801283

12811284
Resolve error ``Unable to find package 'python'`` from a misconfigured ``nuget.config`` using::
12821285

@@ -1293,8 +1296,8 @@ for the 64-bit version, `pythonx86-freethreaded
12931296
<https://www.nuget.org/packages/pythonx86-freethreaded>`_ for the 32-bit
12941297
version, and `pythonarm64-freethreaded
12951298
<https://www.nuget.org/packages/pythonarm64-freethreaded>`_ for the ARM64
1296-
version. These packages contain both the ``python3.13t.exe`` and
1297-
``python.exe`` entry points, both of which run free threaded.
1299+
version. These packages contain both the |python_x_dot_y_t_exe_literal| and
1300+
``python.exe`` entry points, both of which run free-threaded.
12981301

12991302

13001303
Alternative bundles
@@ -1331,8 +1334,8 @@ Supported Windows versions
13311334
As specified in :pep:`11`, a Python release only supports a Windows platform
13321335
while Microsoft considers the platform under extended support. This means that
13331336
Python |version| supports Windows 10 and newer. If you require Windows 7
1334-
support, please install Python 3.8. If you require Windows 8.1 support,
1335-
please install Python 3.12.
1337+
support, install Python 3.8. If you require Windows 8.1 support,
1338+
install Python 3.12.
13361339

13371340

13381341
.. _max-path:
@@ -1416,7 +1419,7 @@ Windows:
14161419
* If the environment variable :envvar:`PYTHONPATH` exists, as described in
14171420
:ref:`using-on-envvars`, its entries are added next. Note that on Windows,
14181421
paths in this variable must be separated by semicolons, to distinguish them
1419-
from the colon used in drive identifiers (``C:\`` etc.).
1422+
from the colon used in drive identifiers (such as ``C:\``).
14201423

14211424
* Additional "application paths" can be added in the registry as subkeys of
14221425
:samp:`\\SOFTWARE\\Python\\PythonCore\\{version}\\PythonPath` under both the
@@ -1429,13 +1432,13 @@ Windows:
14291432
"Python Home". Otherwise, the path of the main Python executable is used to
14301433
locate a "landmark file" (either ``Lib\os.py`` or ``pythonXY.zip``) to deduce
14311434
the "Python Home". If a Python home is found, the relevant sub-directories
1432-
added to :data:`sys.path` (``Lib``, ``plat-win``, etc) are based on that
1435+
added to :data:`sys.path` (such as ``Lib`` and ``plat-win``) are based on that
14331436
folder. Otherwise, the core Python path is constructed from the PythonPath
14341437
stored in the registry.
14351438

14361439
* If the Python Home cannot be located, no :envvar:`PYTHONPATH` is specified in
14371440
the environment, and no registry entries can be found, a default path with
1438-
relative entries is used (e.g. ``.\Lib;.\plat-win``, etc).
1441+
relative entries is used (for example, ``.\Lib;.\plat-win``).
14391442

14401443
If a ``pyvenv.cfg`` file is found alongside the main executable or in the
14411444
directory one level above the executable, the following variations apply:
@@ -1451,11 +1454,11 @@ The end result of all this is:
14511454
directory), the core path is deduced, and the core paths in the registry are
14521455
ignored. Other "application paths" in the registry are always read.
14531456

1454-
* When Python is hosted in another .exe (different directory, embedded via COM,
1455-
etc), the "Python Home" will not be deduced, so the core path from the
1457+
* When Python is hosted in another .exe (for example, in a different directory or
1458+
embedded via COM), the "Python Home" will not be deduced, so the core path from the
14561459
registry is used. Other "application paths" in the registry are always read.
14571460

1458-
* If Python can't find its home and there are no registry value (frozen .exe,
1461+
* If Python can't find its home and there are no registry values (frozen .exe,
14591462
some very strange installation setup) you get a path with some default, but
14601463
relative, paths.
14611464

@@ -1467,7 +1470,7 @@ following advice will prevent conflicts with other installations:
14671470
environment variables, and also ignore :mod:`site` unless ``import site`` is
14681471
listed.
14691472

1470-
* If you are loading :file:`python3.dll` or :file:`python37.dll` in your own
1473+
* If you are loading :file:`python3.dll` or |python_xy_dll_literal| in your own
14711474
executable, explicitly set :c:member:`PyConfig.module_search_paths` before
14721475
:c:func:`Py_InitializeFromConfig`.
14731476

@@ -1488,7 +1491,7 @@ non-standard paths in the registry and user site-packages.
14881491

14891492
.. versionchanged:: 3.6
14901493

1491-
Add ``._pth`` file support and removes ``applocal`` option from
1494+
Add ``._pth`` file support and remove ``applocal`` option from
14921495
``pyvenv.cfg``.
14931496

14941497
.. versionchanged:: 3.6

0 commit comments

Comments
 (0)