https://github.com/python/cpython/commit/e28a2f493044ecfc0f76fe78ff6dde8e395504a9
commit: e28a2f493044ecfc0f76fe78ff6dde8e395504a9
branch: main
author: Steve Dower <[email protected]>
committer: zooba <[email protected]>
date: 2026-06-04T21:37:18+01:00
summary:

Add shebang documentation for PyManager 26.3b1 (GH-150931)

files:
M Doc/using/windows.rst

diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst
index eea1e2f64a468d0..5b715d4614dad8f 100644
--- a/Doc/using/windows.rst
+++ b/Doc/using/windows.rst
@@ -455,6 +455,12 @@ customization.
        Python runtimes, or false to prevent it.
        By default, true.
 
+   * - ``shebang_templates``
+     - (none)
+     - Mapping from shebang line template to alternative command, such as
+       ``py -V:<tag>`` or a substitute string.
+       See :ref:`pymanager-shebang` for more details.
+
    * - ``log_level``
      - ``PYMANAGER_VERBOSE``, ``PYMANAGER_DEBUG``
      - Set the default level of output (0-50).
@@ -568,6 +574,30 @@ which the path to the script and any additional arguments 
will be appended.
 This functionality may be disabled by the ``shebang_can_run_anything``
 configuration option.
 
+Since version 26.3 of the Python install manager, custom shebang templates may
+be added to your configuration file. Add the ``shebang_templates`` object with
+one member for each template (the string to match) and the command to use when
+the template is matched. Most commands should be ``py -V:<tag>`` (or ``pyw``) 
to
+launch one of your installed runtimes. The ``py -3.<version>`` form is also
+allowed, as is a plain ``py`` to launch the default. No other arguments are
+supported.
+
+.. code:: json5
+
+   {
+       "shebang_templates": {
+           "/usr/bin/python": "py",
+           "/usr/bin/my_custom_python": "py -V:MyCustomPython/3"
+       }
+   }
+
+If the substitute command is not ``py`` or ``pyw``, it will be written back 
into
+the shebang and regular handling continues. If launching arbitrary executables
+is permitted, then providing a full path will allow you to redirect from Python
+to any executable. The template should match either the entire line (ignoring
+leading and trailing whitespace), or up to the first space in the shebang line.
+
+
 .. note::
 
    The behaviour of shebangs in the Python install manager is subtly different

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to