diff options
| author | Bernát Gábor <bgabor8@bloomberg.net> | 2021-01-10 12:23:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-10 12:23:14 +0000 |
| commit | 684a632c714b06a76bb6ddc217eaa0df7b40976f (patch) | |
| tree | 1c7dde851d67b9619c606da89e740ace970389a2 /src/virtualenv/create | |
| parent | 9201a757d0582a8181914dc7a9c863daa136a4b8 (diff) | |
| download | virtualenv-684a632c714b06a76bb6ddc217eaa0df7b40976f.tar.gz | |
Improve discovery on Windows and provide escape hatchet (#2046)
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
Diffstat (limited to 'src/virtualenv/create')
| -rw-r--r-- | src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py b/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py index 1938509..ad73eed 100644 --- a/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py +++ b/src/virtualenv/create/via_global_ref/builtin/cpython/cpython3.py @@ -55,20 +55,27 @@ class CPython3Windows(CPythonWindows, CPython3): def sources(cls, interpreter): for src in super(CPython3Windows, cls).sources(interpreter): yield src - if not cls.venv_37p(interpreter): + if not cls.has_shim(interpreter): for src in cls.include_dll_and_pyd(interpreter): yield src - @staticmethod - def venv_37p(interpreter): - return interpreter.version_info.minor >= 7 + @classmethod + def has_shim(cls, interpreter): + return interpreter.version_info.minor >= 7 and cls.shim(interpreter) is not None + + @classmethod + def shim(cls, interpreter): + shim = Path(interpreter.system_stdlib) / "venv" / "scripts" / "nt" / "python.exe" + if shim.exists(): + return shim + return None @classmethod def host_python(cls, interpreter): - if cls.venv_37p(interpreter): + if cls.has_shim(interpreter): # starting with CPython 3.7 Windows ships with a venvlauncher.exe that avoids the need for dll/pyd copies # it also means the wrapper must be copied to avoid bugs such as https://bugs.python.org/issue42013 - return Path(interpreter.system_stdlib) / "venv" / "scripts" / "nt" / "python.exe" + return cls.shim(interpreter) return super(CPython3Windows, cls).host_python(interpreter) @classmethod |
