diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-08-05-15-15-09.gh-issue-107658.wGMCYf.rst b/Misc/NEWS.d/next/Core and Builtins/2023-08-05-15-15-09.gh-issue-107658.wGMCYf.rst new file mode 100644 index 00000000000000..58328550bb55ce --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-08-05-15-15-09.gh-issue-107658.wGMCYf.rst @@ -0,0 +1 @@ +Use same logic to look for exec_prefix as for prefix diff --git a/Modules/getpath.py b/Modules/getpath.py index 9913fcba497d30..db762c6956a970 100644 --- a/Modules/getpath.py +++ b/Modules/getpath.py @@ -594,6 +594,12 @@ def search_up(prefix, *landmarks, test=isfile): prefix = abspath('') warn('Could not find platform independent libraries ') + # First try to detect exec_prefix by looking alongside our runtime library, if known + if library and not exec_prefix: + library_dir = dirname(library) + if PLATSTDLIB_LANDMARK: + if isdir(joinpath(library_dir, PLATSTDLIB_LANDMARK)): + exec_prefix = library_dir # Detect exec_prefix by searching from executable for the platstdlib_dir if PLATSTDLIB_LANDMARK and not exec_prefix: