cpython: 2eb99070a38f (original) (raw)

Mercurial > cpython

changeset 94764:2eb99070a38f

Issue #23465: Implement PEP 486 - Make the Python Launcher aware of virtual environments (patch by Paul Moore) [#23465]

Steve Dower steve.dower@microsoft.com
date Thu, 26 Feb 2015 14:25:33 -0800
parents 7c6e3358221a
children 9b9887bd7734
files Doc/using/windows.rst Doc/whatsnew/3.5.rst Misc/NEWS PC/launcher.c
diffstat 4 files changed, 73 insertions(+), 4 deletions(-)[+] [-] Doc/using/windows.rst 20 Doc/whatsnew/3.5.rst 12 Misc/NEWS 3 PC/launcher.c 42

line wrap: on

line diff

--- a/Doc/using/windows.rst +++ b/Doc/using/windows.rst @@ -404,6 +404,16 @@ If you see the following error, you do n Per-user installations of Python do not add the launcher to :envvar:PATH unless the option was selected on installation. +Virtual environments +^^^^^^^^^^^^^^^^^^^^ + +If the launcher is run with no explicit Python version specification, and a +virtual environment (created with the standard library :mod:venv module or +the external virtualenv tool) active, the launcher will run the virtual +environment's interpreter rather than the global one. To run the global +interpreter, either deactivate the virtual environment, or explicitly specify +the global Python version. + From a script ^^^^^^^^^^^^^ @@ -478,6 +488,16 @@ be used by the launcher without modifica 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) - for example +/usr/bin/python2.7 - which will cause that specific version to be located +and used. + +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. This corresponds to the +behaviour of the Unix env program, which performs a :envvar:PATH search. + Arguments in shebang lines --------------------------

--- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -123,6 +123,18 @@ manually, and should make it more robust :pep:475 -- Retry system calls failing with EINTR +PEP 486: Make the Python Launcher aware of virtual environments +--------------------------------------------------------------- + +:pep:486 makes the Windows launcher (see :pep:397) aware of an active +virtual environment. When the default interpreter would be used and the +VIRTUAL_ENV environment variable is set, the interpreter in the virtual +environment will be used. + +.. seealso:: +

+ Other Language Changes ======================

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -77,6 +77,9 @@ Build Windows ------- +- Issue #23465: Implement PEP 486 - Make the Python Launcher aware of virtual

--- a/PC/launcher.c +++ b/PC/launcher.c @@ -384,6 +384,31 @@ find_python_by_version(wchar_t const * w } +static wchar_t * +find_python_by_venv() +{

+

+

+

+} + static wchar_t appdata_ini_path[MAX_PATH]; static wchar_t launcher_ini_path[MAX_PATH]; @@ -1309,6 +1334,7 @@ process(int argc, wchar_t ** argv) { wchar_t * wp; wchar_t * command;

installed", &p[1]);

@@ -1470,9 +1497,16 @@ installed", &p[1]); #endif if (!valid) {

+

#if defined(_M_X64) BOOL canDo64bit = TRUE; @@ -1500,7 +1534,7 @@ Launcher arguments:\n\n[](#l4.71) fflush(stdout); } }