mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03: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
|
|
@ -875,6 +875,11 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
|
|||
!decode_to_dict(dict, "os_name", "darwin") ||
|
||||
#else
|
||||
!decode_to_dict(dict, "os_name", "posix") ||
|
||||
#endif
|
||||
#ifdef WITH_NEXT_FRAMEWORK
|
||||
!int_to_dict(dict, "WITH_NEXT_FRAMEWORK", 1) ||
|
||||
#else
|
||||
!int_to_dict(dict, "WITH_NEXT_FRAMEWORK", 0) ||
|
||||
#endif
|
||||
!decode_to_dict(dict, "PREFIX", PREFIX) ||
|
||||
!decode_to_dict(dict, "EXEC_PREFIX", EXEC_PREFIX) ||
|
||||
|
|
@ -943,3 +948,4 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
|
|||
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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