mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-46890: Fix setting of sys._base_executable with framework builds on macOS (GH-31958)
The side effect of this bug was that venv environments directly used the main interpreter instead of the intermediate stub executable, which can cause problems when a script uses system APIs that require the use of an application bundle.
This commit is contained in:
parent
a0c700480b
commit
6aaf4cd866
5 changed files with 200 additions and 2 deletions
|
@ -33,6 +33,7 @@
|
|||
# PREFIX -- [in] sysconfig.get_config_var(...)
|
||||
# EXEC_PREFIX -- [in] sysconfig.get_config_var(...)
|
||||
# PYTHONPATH -- [in] sysconfig.get_config_var(...)
|
||||
# WITH_NEXT_FRAMEWORK -- [in] sysconfig.get_config_var(...)
|
||||
# VPATH -- [in] sysconfig.get_config_var(...)
|
||||
# PLATLIBDIR -- [in] sysconfig.get_config_var(...)
|
||||
# PYDEBUGEXT -- [in, opt] '_d' on Windows for debug builds
|
||||
|
@ -301,9 +302,19 @@ if ENV_PYTHONEXECUTABLE or ENV___PYVENV_LAUNCHER__:
|
|||
# If set, these variables imply that we should be using them as
|
||||
# sys.executable and when searching for venvs. However, we should
|
||||
# use the argv0 path for prefix calculation
|
||||
base_executable = executable
|
||||
|
||||
if os_name == 'darwin' and WITH_NEXT_FRAMEWORK:
|
||||
# In a framework build the binary in {sys.exec_prefix}/bin is
|
||||
# a stub executable that execs the real interpreter in an
|
||||
# embedded app bundle. That bundle is an implementation detail
|
||||
# and should not affect base_executable.
|
||||
base_executable = f"{dirname(library)}/bin/python{VERSION_MAJOR}.{VERSION_MINOR}"
|
||||
else:
|
||||
base_executable = executable
|
||||
|
||||
if not real_executable:
|
||||
real_executable = executable
|
||||
real_executable = base_executable
|
||||
#real_executable_dir = dirname(real_executable)
|
||||
executable = ENV_PYTHONEXECUTABLE or ENV___PYVENV_LAUNCHER__
|
||||
executable_dir = dirname(executable)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue