mirror of https://github.com/python/cpython
gh-117786: Fix venv created from Windows Store install by restoring __PYVENV_LAUNCHER__ smuggling (GH-117814)
This commit is contained in:
parent
8942bf41da
commit
4b10e209c7
|
@ -747,6 +747,9 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
|
||||||
if value is self.IGNORE_CONFIG:
|
if value is self.IGNORE_CONFIG:
|
||||||
config.pop(key, None)
|
config.pop(key, None)
|
||||||
del expected[key]
|
del expected[key]
|
||||||
|
# Resolve bool/int mismatches to reduce noise in diffs
|
||||||
|
if isinstance(value, (bool, int)) and isinstance(config.get(key), (bool, int)):
|
||||||
|
expected[key] = type(config[key])(expected[key])
|
||||||
self.assertEqual(config, expected)
|
self.assertEqual(config, expected)
|
||||||
|
|
||||||
def check_global_config(self, configs):
|
def check_global_config(self, configs):
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fixes virtual environments not correctly launching when created from a Store
|
||||||
|
install.
|
|
@ -310,7 +310,10 @@ if ENV_PYTHONEXECUTABLE or ENV___PYVENV_LAUNCHER__:
|
||||||
# and should not affect base_executable.
|
# and should not affect base_executable.
|
||||||
base_executable = f"{dirname(library)}/bin/python{VERSION_MAJOR}.{VERSION_MINOR}"
|
base_executable = f"{dirname(library)}/bin/python{VERSION_MAJOR}.{VERSION_MINOR}"
|
||||||
else:
|
else:
|
||||||
base_executable = executable
|
# Use the real executable as our base, or argv[0] otherwise
|
||||||
|
# (on Windows, argv[0] is likely to be ENV___PYVENV_LAUNCHER__; on
|
||||||
|
# other platforms, real_executable is likely to be empty)
|
||||||
|
base_executable = real_executable or executable
|
||||||
|
|
||||||
if not real_executable:
|
if not real_executable:
|
||||||
real_executable = base_executable
|
real_executable = base_executable
|
||||||
|
@ -408,13 +411,14 @@ if not base_executable:
|
||||||
if not real_executable:
|
if not real_executable:
|
||||||
real_executable = base_executable
|
real_executable = base_executable
|
||||||
|
|
||||||
try:
|
if real_executable:
|
||||||
real_executable = realpath(real_executable)
|
try:
|
||||||
except OSError as ex:
|
real_executable = realpath(real_executable)
|
||||||
# Only warn if the file actually exists and was unresolvable
|
except OSError as ex:
|
||||||
# Otherwise users who specify a fake executable may get spurious warnings.
|
# Only warn if the file actually exists and was unresolvable
|
||||||
if isfile(real_executable):
|
# Otherwise users who specify a fake executable may get spurious warnings.
|
||||||
warn(f'Failed to find real location of {base_executable}')
|
if isfile(real_executable):
|
||||||
|
warn(f'Failed to find real location of {base_executable}')
|
||||||
|
|
||||||
if not executable_dir and os_name == 'darwin' and library:
|
if not executable_dir and os_name == 'darwin' and library:
|
||||||
# QUIRK: macOS checks adjacent to its library early
|
# QUIRK: macOS checks adjacent to its library early
|
||||||
|
@ -427,12 +431,12 @@ if not executable_dir and os_name == 'darwin' and library:
|
||||||
|
|
||||||
# If we do not have the executable's directory, we can calculate it.
|
# If we do not have the executable's directory, we can calculate it.
|
||||||
# This is the directory used to find prefix/exec_prefix if necessary.
|
# This is the directory used to find prefix/exec_prefix if necessary.
|
||||||
if not executable_dir:
|
if not executable_dir and real_executable:
|
||||||
executable_dir = real_executable_dir = dirname(real_executable)
|
executable_dir = real_executable_dir = dirname(real_executable)
|
||||||
|
|
||||||
# If we do not have the real executable's directory, we calculate it.
|
# If we do not have the real executable's directory, we calculate it.
|
||||||
# This is the directory used to detect build layouts.
|
# This is the directory used to detect build layouts.
|
||||||
if not real_executable_dir:
|
if not real_executable_dir and real_executable:
|
||||||
real_executable_dir = dirname(real_executable)
|
real_executable_dir = dirname(real_executable)
|
||||||
|
|
||||||
# ******************************************************************************
|
# ******************************************************************************
|
||||||
|
|
|
@ -484,8 +484,8 @@ process(int argc, wchar_t ** argv)
|
||||||
|
|
||||||
// We do not update argv[0] to point at the target runtime, and so we do not
|
// We do not update argv[0] to point at the target runtime, and so we do not
|
||||||
// pass through our original argv[0] in an environment variable.
|
// pass through our original argv[0] in an environment variable.
|
||||||
//exitCode = smuggle_path();
|
exitCode = smuggle_path();
|
||||||
//if (exitCode) return exitCode;
|
if (exitCode) return exitCode;
|
||||||
|
|
||||||
exitCode = launch(home_path, GetCommandLineW());
|
exitCode = launch(home_path, GetCommandLineW());
|
||||||
return exitCode;
|
return exitCode;
|
||||||
|
|
Loading…
Reference in New Issue