From ee3503b25b0c475fc9dee74398107fc61ca411ab Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 22 Feb 2021 14:13:22 +0100 Subject: [PATCH] Adjust static libpython detection `dladdr` may only return the basename of the executable image, so we have to adjust the lookup accordingly. --- pythonnet/find_libpython/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pythonnet/find_libpython/__init__.py b/pythonnet/find_libpython/__init__.py index 3ae28970e..91c066a52 100644 --- a/pythonnet/find_libpython/__init__.py +++ b/pythonnet/find_libpython/__init__.py @@ -91,6 +91,11 @@ def _linked_libpython_unix(): if retcode == 0: # means error return None path = os.path.realpath(dlinfo.dli_fname.decode()) + + # Compare basenames only, this should always be enough except for very + # pathological cases + if os.path.basename(path) == os.path.basename(os.path.realpath(sys.executable)): + return None return path