File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def _find_library(name):
4141 import os
4242 from distutils .sysconfig import get_python_lib
4343 try :
44- lib = ctypes .CDLL (os .path .join (get_python_lib (), 'lib%s.so' % ( name ) ),
44+ lib = ctypes .CDLL (os .path .join (get_python_lib (), name ),
4545 mode = ctypes .RTLD_GLOBAL )
4646 return lib
4747 except :
@@ -50,8 +50,7 @@ def _find_library(name):
5050 import sys
5151 for p in sys .path :
5252 try :
53- lib = ctypes .CDLL (os .path .join (p , 'lib%s.so' % (name )),
54- mode = ctypes .RTLD_GLOBAL )
53+ lib = ctypes .CDLL (os .path .join (p , name ), mode = ctypes .RTLD_GLOBAL )
5554 return lib
5655 except :
5756 pass
@@ -64,9 +63,21 @@ def find_library(*names):
6463 lib = _find_library (name )
6564 if lib is not None :
6665 break
66+ if not name .startswith ("lib" ):
67+ lib = _find_library ("lib" + name )
68+ if lib is not None :
69+ break
70+ if not name .endswith (".so" ):
71+ lib = _find_library (name + ".so" )
72+ if lib is not None :
73+ break
74+ if not name .startswith ("lib" ) and not name .endswith (".so" ):
75+ lib = _find_library ("lib" + name + ".so" )
76+ if lib is not None :
77+ break
6778 if lib :
6879 major = 0
69- m = re .match ( "libxtables .so.(\d+)" , lib ._name )
80+ m = re .search ( r"\ .so\ .(\d+)" , lib ._name )
7081 if m :
7182 major = int (m .group (1 ))
7283 return lib , major
You can’t perform that action at this time.
0 commit comments