File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -306,10 +306,38 @@ def _findLib_ld(name):
306
306
pass # result will be None
307
307
return result
308
308
309
+
310
+ def _findLib_walkldpath (name ):
311
+
312
+ def _is_elf (filepath ):
313
+ try :
314
+ with open (filepath , 'rb' ) as fh :
315
+ return fh .read (4 ) == b'\x7f ELF'
316
+ except :
317
+ return False
318
+
319
+ from glob import glob
320
+ if os .path .isabs (name ):
321
+ return name
322
+ # search LD_LIBRARY_PATH list
323
+ paths = os .environ .get ('LD_LIBRARY_PATH' , '' ).split (':' )
324
+ if paths :
325
+ for d in paths :
326
+ f = os .path .join (d , name )
327
+ if _is_elf (f ):
328
+ return os .path .basename (f )
329
+ prefix = os .path .join (d , 'lib' + name )
330
+ for suffix in ['.so' , '.so.*' ]:
331
+ for f in glob ('{0}{1}' .format (prefix , suffix )):
332
+ if _is_elf (f ):
333
+ return os .path .basename (f )
334
+
309
335
def find_library (name ):
310
336
# See issue #9998
311
337
return _findSoname_ldconfig (name ) or \
312
- _get_soname (_findLib_gcc (name ) or _findLib_ld (name ))
338
+ _get_soname (_findLib_gcc (name ) or \
339
+ _findLib_ld (name )) or \
340
+ _findLib_walkldpath (name )
313
341
314
342
################################################################
315
343
# test code
You can’t perform that action at this time.
0 commit comments