mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-83180: Made launcher treat shebang 'python' tags as low priority so that active virtual environments are preferred (GH-108101)
This commit is contained in:
parent
6139bf5e0c
commit
1b3bc610fd
4 changed files with 71 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue