GH-128469: warn when libpython was loaded from outside the build directory (#128645)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Filipe Laíns 🇵🇸 2025-01-29 22:35:55 +00:00 committed by GitHub
parent a1a4e9f39a
commit 29b3ce8355
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 50 additions and 0 deletions

View file

@ -785,6 +785,19 @@ if os_name != 'nt' and build_prefix:
base_exec_prefix = config.get('base_exec_prefix') or EXEC_PREFIX or base_prefix
# ******************************************************************************
# MISC. RUNTIME WARNINGS
# ******************************************************************************
# When running Python from the build directory, if libpython is dynamically
# linked, the wrong library might be loaded.
if build_prefix and library and not dirname(abspath(library)).startswith(build_prefix):
msg = f'The runtime library has been loaded from outside the build directory ({library})!'
if os_name == 'posix':
msg += ' Consider setting LD_LIBRARY_PATH=. to force it to be loaded from the build directory.'
warn(msg)
# ******************************************************************************
# SET pythonpath FROM _PTH FILE
# ******************************************************************************