From 4aa7ee5de0db8b02438264bd80a82722dadc4192 Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 7 May 2022 05:58:46 +0900 Subject: [PATCH 1/3] _PyPathConfig structure has _is_python_build --- Python/pathconfig.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 4271928571fa1f..05498ba4386336 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -36,6 +36,7 @@ typedef struct _PyPathConfig { wchar_t *program_name; /* Set by Py_SetPythonHome() or PYTHONHOME environment variable */ wchar_t *home; + int _is_python_build; } _PyPathConfig; # define _PyPathConfig_INIT \ @@ -105,6 +106,7 @@ _PyPathConfig_ReadGlobal(PyConfig *config) COPY(program_name); COPY(home); COPY2(executable, program_full_path); + config->_is_python_build = _Py_path_config._is_python_build; // module_search_path must be initialised - not read #undef COPY #undef COPY2 @@ -143,6 +145,7 @@ _PyPathConfig_UpdateGlobal(const PyConfig *config) COPY(program_name); COPY(home); COPY2(program_full_path, executable); + _Py_path_config._is_python_build = config->_is_python_build; #undef COPY #undef COPY2 From 71fdc8d11cbf7e933f41a0caf8c9535b5e45e849 Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 7 May 2022 06:46:24 +0900 Subject: [PATCH 2/3] Use _is_python_build in getpath.py --- Modules/getpath.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/getpath.py b/Modules/getpath.py index 9aff19c0af7edd..4fc9a092939f24 100644 --- a/Modules/getpath.py +++ b/Modules/getpath.py @@ -460,7 +460,8 @@ def search_up(prefix, *landmarks, test=isfile): build_prefix = None -if not home_was_set and real_executable_dir and not py_setpath: +if (not home_was_set and real_executable_dir and not py_setpath) or \ + config.get('_is_python_build'): # Detect a build marker and use it to infer prefix, exec_prefix, # stdlib_dir and the platstdlib_dir directories. try: From 7ce060314e5d28e3eb5837d2ac1d182f1a5a962e Mon Sep 17 00:00:00 2001 From: neonene <53406459+neonene@users.noreply.github.com> Date: Sat, 7 May 2022 08:01:37 +0900 Subject: [PATCH 3/3] Update pathconfig.c --- Python/pathconfig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 05498ba4386336..8c816b5c697745 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -73,6 +73,7 @@ _PyPathConfig_ClearGlobal(void) CLEAR(calculated_module_search_path); CLEAR(program_name); CLEAR(home); + _Py_path_config._is_python_build = 0; #undef CLEAR