diff options
author | Steve Dower <steve.dower@microsoft.com> | 2018-12-10 16:11:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-10 16:11:21 (GMT) |
commit | 1c3de541e64f75046b20cdd27bada1557e550bcd (patch) | |
tree | 958a34f1023404eb33b87a55ed52b34e3702ccd8 /PC/getpathp.c | |
parent | b6ef6f69a9afc979640a5f9883f799de1364bff7 (diff) | |
download | cpython-1c3de541e64f75046b20cdd27bada1557e550bcd.zip cpython-1c3de541e64f75046b20cdd27bada1557e550bcd.tar.gz cpython-1c3de541e64f75046b20cdd27bada1557e550bcd.tar.bz2 |
bpo-34977: Use venv redirector instead of original python.exe on Windows (GH-11029)
Diffstat (limited to 'PC/getpathp.c')
-rw-r--r-- | PC/getpathp.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c index 35c31bf..76d3a08 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -536,10 +536,16 @@ static _PyInitError get_program_full_path(const _PyCoreConfig *core_config, PyCalculatePath *calculate, _PyPathConfig *config) { + const wchar_t *pyvenv_launcher; wchar_t program_full_path[MAXPATHLEN+1]; memset(program_full_path, 0, sizeof(program_full_path)); - if (!GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) { + /* The launcher may need to force the executable path to a + * different environment, so override it here. */ + pyvenv_launcher = _wgetenv(L"__PYVENV_LAUNCHER__"); + if (pyvenv_launcher && pyvenv_launcher[0]) { + wcscpy_s(program_full_path, MAXPATHLEN+1, pyvenv_launcher); + } else if (!GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) { /* GetModuleFileName should never fail when passed NULL */ return _Py_INIT_ERR("Cannot determine program path"); } |