Skip to content

Commit e28a2f4

Browse files
authored
Add shebang documentation for PyManager 26.3b1 (GH-150931)
1 parent f906522 commit e28a2f4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Doc/using/windows.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,12 @@ customization.
455455
Python runtimes, or false to prevent it.
456456
By default, true.
457457

458+
* - ``shebang_templates``
459+
- (none)
460+
- Mapping from shebang line template to alternative command, such as
461+
``py -V:<tag>`` or a substitute string.
462+
See :ref:`pymanager-shebang` for more details.
463+
458464
* - ``log_level``
459465
- ``PYMANAGER_VERBOSE``, ``PYMANAGER_DEBUG``
460466
- 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.
568574
This functionality may be disabled by the ``shebang_can_run_anything``
569575
configuration option.
570576

577+
Since version 26.3 of the Python install manager, custom shebang templates may
578+
be added to your configuration file. Add the ``shebang_templates`` object with
579+
one member for each template (the string to match) and the command to use when
580+
the template is matched. Most commands should be ``py -V:<tag>`` (or ``pyw``) to
581+
launch one of your installed runtimes. The ``py -3.<version>`` form is also
582+
allowed, as is a plain ``py`` to launch the default. No other arguments are
583+
supported.
584+
585+
.. code:: json5
586+
587+
{
588+
"shebang_templates": {
589+
"/usr/bin/python": "py",
590+
"/usr/bin/my_custom_python": "py -V:MyCustomPython/3"
591+
}
592+
}
593+
594+
If the substitute command is not ``py`` or ``pyw``, it will be written back into
595+
the shebang and regular handling continues. If launching arbitrary executables
596+
is permitted, then providing a full path will allow you to redirect from Python
597+
to any executable. The template should match either the entire line (ignoring
598+
leading and trailing whitespace), or up to the first space in the shebang line.
599+
600+
571601
.. note::
572602

573603
The behaviour of shebangs in the Python install manager is subtly different

0 commit comments

Comments
 (0)