summaryrefslogtreecommitdiff
path: root/PC/getpathp.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2018-12-06 21:09:20 -0800
committerGitHub <noreply@github.com>2018-12-06 21:09:20 -0800
commit468a15aaf9206448a744fc5eab3fc21f51966aad (patch)
tree75c8f2aae7835ae7ca718ef8660a4c0899837bd3 /PC/getpathp.c
parentc9566b8c454120e3d0ddb5ab970f262a6cd80077 (diff)
downloadcpython-git-468a15aaf9206448a744fc5eab3fc21f51966aad.tar.gz
bpo-34977: Add Windows App Store package (GH-10245)
Diffstat (limited to 'PC/getpathp.c')
-rw-r--r--PC/getpathp.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c
index 25f371fc9f..452501a9a8 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");
}