Skip to content

Commit c4f2ad7

Browse files
authored
Adjust static libpython detection (#1396)
* Check for Py_ENABLE_SHARED on Unix
1 parent 6f1219f commit c4f2ad7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pythonnet/find_libpython/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ class Dl_info(ctypes.Structure):
7777

7878

7979
def _linked_libpython_unix():
80+
if not sysconfig.get_config_var("Py_ENABLE_SHARED"):
81+
return None
82+
8083
libdl = ctypes.CDLL(ctypes.util.find_library("dl"))
8184
libdl.dladdr.argtypes = [ctypes.c_void_p, ctypes.POINTER(Dl_info)]
8285
libdl.dladdr.restype = ctypes.c_int
@@ -88,8 +91,6 @@ def _linked_libpython_unix():
8891
if retcode == 0: # means error
8992
return None
9093
path = os.path.realpath(dlinfo.dli_fname.decode())
91-
if path == os.path.realpath(sys.executable):
92-
return None
9394
return path
9495

9596

0 commit comments

Comments
 (0)