Skip to content

Commit 867cda8

Browse files
committed
GH-128469: warn when libpython was loaded from outside the build directory
Signed-off-by: Filipe Laíns <[email protected]
1 parent 004f9fd commit 867cda8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Modules/getpath.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,19 @@ def search_up(prefix, *landmarks, test=isfile):
783783
base_exec_prefix = config.get('base_exec_prefix') or EXEC_PREFIX or base_prefix
784784

785785

786+
# ******************************************************************************
787+
# MISC. RUNTIME WARNINGS
788+
# ******************************************************************************
789+
790+
# When running Python from the build directory, if libpython is dynamically
791+
# linked, the wrong library might be loaded.
792+
if build_prefix and not build_prefix.startswith(dirname(abspath(library))):
793+
msg = f'The runtime library has been loaded from outside the build directory ({library})!'
794+
if os_name == 'posix':
795+
msg += ' Consider setting LD_LIBRARY_PATH=. to force it to be loaded from the build directory.'
796+
warn(msg)
797+
798+
786799
# ******************************************************************************
787800
# SET pythonpath FROM _PTH FILE
788801
# ******************************************************************************

0 commit comments

Comments
 (0)