Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Check for Py_ENABLE_SHARED on Unix
  • Loading branch information
filmor committed Feb 22, 2021
commit 2a33bed9b3b7da30fb2a9217733f7977ef26a74f
10 changes: 4 additions & 6 deletions pythonnet/find_libpython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Dl_info(ctypes.Structure):


def _linked_libpython_unix():
if not sysconfig.get_config_var("Py_ENABLE_SHARED"):
return None

libdl = ctypes.CDLL(ctypes.util.find_library("dl"))
libdl.dladdr.argtypes = [ctypes.c_void_p, ctypes.POINTER(Dl_info)]
libdl.dladdr.restype = ctypes.c_int
Expand All @@ -87,12 +90,7 @@ def _linked_libpython_unix():
ctypes.pointer(dlinfo))
if retcode == 0: # means error
return None
path = 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
path = os.path.realpath(dlinfo.dli_fname.decode())
return path


Expand Down