[Python-checkins] peps: Apply PEP 486 changes from Paul Moore

chris.angelico python-checkins at python.org
Sat Feb 14 16:34:21 CET 2015


https://hg.python.org/peps/rev/d81a7d2993b5
changeset:   5696:d81a7d2993b5
user:        Chris Angelico <rosuav at gmail.com>
date:        Sun Feb 15 02:33:55 2015 +1100
summary:
  Apply PEP 486 changes from Paul Moore

files:
  pep-0486.txt |  38 +++++++++++++++++++-------------------
  1 files changed, 19 insertions(+), 19 deletions(-)


diff --git a/pep-0486.txt b/pep-0486.txt
--- a/pep-0486.txt
+++ b/pep-0486.txt
@@ -83,6 +83,7 @@
 Impact on Script Launching
 ==========================
 
+
 As well as interactive use, the launcher is used as the Windows file
 association for Python scripts.  In that case, a "shebang" (``#!``)
 line at the start of the script is used to identify the interpreter to
@@ -90,26 +91,18 @@
 (``python3`` or ``python2``, or even ``python3.5``), or the generic
 ``python``, which means to use the default interpreter.
 
-With the proposed change, scripts that start with ``#!python`` (or one
-of its equivalent forms) will be run using an active virtualenv.  This
-is a change in behaviour, although it will only affect users running
-scripts from the command line with a virtualenv activated.
+The launcher also looks for the specific shebang line
+``#!/usr/bin/env python``. On Unix, the ``env`` program searches for a
+command on ``$PATH`` and runs the command so located. Similarly, with
+this shebang line, the launcher will look for a copy of ``python.exe``
+on the user's current ``%PATH%`` and will run that copy.
 
-Under Unix, the ``#!/usr/bin/env python`` shebang line will use the
-version of Python found on ``$PATH``, whereas ``#!/usr/bin/python``
-will use the system Python.  In order to match Unix behaviour as
-closely as possible, it is proposed that the two shebang forms::
-
-    #!/usr/bin/env python
-    #!python
-
-use an active virtualenv, if present, whereas the forms::
-
-    #!/usr/bin/python
-    #!/usr/local/bin/python
-
-use *only* the default system Python, and ignore the ``VIRTUAL_ENV``
-environment variable.
+As activating a virtualenv means that it is added to ``PATH``, no
+special handling is needed to run scripts with the active virtualenv -
+they just need to use the ``#!/usr/bin/env python`` shebang line,
+exactly as on Unix. (If there is no activated virtualenv, and no
+``python.exe`` on ``PATH``, the launcher will look for a default
+Python exactly as if the shebang line had said ``#!python``).
 
 
 Exclusions
@@ -126,6 +119,13 @@
 to do so when using virtual environments.
 
 
+Reference Implementation
+========================
+
+A patch implementing the proposed behaviour is available at
+http://bugs.python.org/issue23465
+
+
 References
 ==========
 

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list