summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2023-10-02 12:22:55 (GMT)
committerGitHub <noreply@github.com>2023-10-02 12:22:55 (GMT)
commit1b3bc610fd40e7c26ecb98e92f37c4ed17625c41 (patch)
tree135b2fdcc2f312c67ea3fde207345502ca3d719a /Doc
parent6139bf5e0c755ed22bdfb027a5299493f0c71be9 (diff)
downloadcpython-1b3bc610fd40e7c26ecb98e92f37c4ed17625c41.zip
cpython-1b3bc610fd40e7c26ecb98e92f37c4ed17625c41.tar.gz
cpython-1b3bc610fd40e7c26ecb98e92f37c4ed17625c41.tar.bz2
gh-83180: Made launcher treat shebang 'python' tags as low priority so that active virtual environments are preferred (GH-108101)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/using/windows.rst20
1 files changed, 14 insertions, 6 deletions
diff --git a/Doc/using/windows.rst b/Doc/using/windows.rst
index 2476e60..51afba9 100644
--- a/Doc/using/windows.rst
+++ b/Doc/using/windows.rst
@@ -867,17 +867,18 @@ For example, if the first line of your script starts with
#! /usr/bin/python
-The default Python will be located and used. As many Python scripts written
-to work on Unix will already have this line, you should find these scripts can
-be used by the launcher without modification. If you are writing a new script
-on Windows which you hope will be useful on Unix, you should use one of the
-shebang lines starting with ``/usr``.
+The default Python or an active virtual environment will be located and used.
+As many Python scripts written to work on Unix will already have this line,
+you should find these scripts can be used by the launcher without modification.
+If you are writing a new script on Windows which you hope will be useful on
+Unix, you should use one of the shebang lines starting with ``/usr``.
Any of the above virtual commands can be suffixed with an explicit version
(either just the major version, or the major and minor version).
Furthermore the 32-bit version can be requested by adding "-32" after the
minor version. I.e. ``/usr/bin/python3.7-32`` will request usage of the
-32-bit python 3.7.
+32-bit Python 3.7. If a virtual environment is active, the version will be
+ignored and the environment will be used.
.. versionadded:: 3.7
@@ -891,6 +892,13 @@ minor version. I.e. ``/usr/bin/python3.7-32`` will request usage of the
not provably i386/32-bit". To request a specific environment, use the new
:samp:`-V:{TAG}` argument with the complete tag.
+.. versionchanged:: 3.13
+
+ Virtual commands referencing ``python`` now prefer an active virtual
+ environment rather than searching :envvar:`PATH`. This handles cases where
+ the shebang specifies ``/usr/bin/env python3`` but :file:`python3.exe` is
+ not present in the active environment.
+
The ``/usr/bin/env`` form of shebang line has one further special property.
Before looking for installed Python interpreters, this form will search the
executable :envvar:`PATH` for a Python executable matching the name provided