@@ -457,6 +457,12 @@ customization.
457457 Python runtimes, or false to prevent it.
458458 By default, true.
459459
460+ * - ``shebang_templates ``
461+ - (none)
462+ - Mapping from shebang line template to alternative command, such as
463+ ``py -V:<tag> `` or a substitute string.
464+ See :ref: `pymanager-shebang ` for more details.
465+
460466 * - ``log_level ``
461467 - ``PYMANAGER_VERBOSE ``, ``PYMANAGER_DEBUG ``
462468 - Set the default level of output (0-50).
@@ -570,6 +576,30 @@ which the path to the script and any additional arguments will be appended.
570576This functionality may be disabled by the ``shebang_can_run_anything ``
571577configuration option.
572578
579+ Since version 26.3 of the Python install manager, custom shebang templates may
580+ be added to your configuration file. Add the ``shebang_templates `` object with
581+ one member for each template (the string to match) and the command to use when
582+ the template is matched. Most commands should be ``py -V:<tag> `` (or ``pyw ``) to
583+ launch one of your installed runtimes. The ``py -3.<version> `` form is also
584+ allowed, as is a plain ``py `` to launch the default. No other arguments are
585+ supported.
586+
587+ .. code :: json5
588+
589+ {
590+ "shebang_templates": {
591+ "/usr/bin/python": "py",
592+ "/usr/bin/my_custom_python": "py -V:MyCustomPython/3"
593+ }
594+ }
595+
596+ If the substitute command is not ``py `` or ``pyw ``, it will be written back into
597+ the shebang and regular handling continues. If launching arbitrary executables
598+ is permitted, then providing a full path will allow you to redirect from Python
599+ to any executable. The template should match either the entire line (ignoring
600+ leading and trailing whitespace), or up to the first space in the shebang line.
601+
602+
573603.. note ::
574604
575605 The behaviour of shebangs in the Python install manager is subtly different
0 commit comments