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: diff --git a/Python/pathconfig.c b/Python/pathconfig.c index 4271928571fa1f..8c816b5c697745 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 \ @@ -72,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 @@ -105,6 +107,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 +146,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