fix lib discovery

LD_LIBRARY_PATH is sometimes empty, this change fix it.
Also test suffix with the "." as it seems to be an issue
This commit is contained in:
benoitc 2019-11-20 21:36:01 +01:00
parent b8860ef615
commit d55c7cb015

View File

@ -650,17 +650,19 @@ def _findWalk_ldpath(name):
return name
# search LD_LIBRARY_PATH list
paths = os.environ.get('LD_LIBRARY_PATH', '').split(':')
if paths:
for d in paths:
f = os.path.join(d, name)
if _is_elf(f):
return os.path.basename(f)
prefix = os.path.join(d, 'lib'+name)
for suffix in ['.so', '.so.*']:
for f in glob('{0}{1}'.format(prefix, suffix)):
if _is_elf(f):
return os.path.basename(f)
paths = ['/lib', '/usr/local/lib', '/usr/lib']
if 'LD_LIBRARY_PATH' in os.environ:
paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
for d in paths:
f = os.path.join(d, name)
if _is_elf(f):
return os.path.basename(f)
prefix = os.path.join(d, 'lib'+name)
for suffix in ['so', 'so.*']:
for f in glob('{0}.{1}'.format(prefix, suffix)):
if _is_elf(f):
return os.path.basename(f)
def find_library(name):