summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-25 12:15:16 +0000
committerGerrit Code Review <review@openstack.org>2019-03-25 12:15:16 +0000
commitd12d90ea87710fb41a8a83da869a1290e9d6de27 (patch)
treecb517bbd31a40129e46bcf4cf2d8d9fa6ede0af8
parent2175baed0ef54e35ad96f96123f08e354403117d (diff)
parent2033d7b362f608a6f8740a81f5ebc75ed45a1022 (diff)
downloadpyeclib-d12d90ea87710fb41a8a83da869a1290e9d6de27.tar.gz
Merge "Try harder to find liberasurecode"
-rw-r--r--setup.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 46a336d..d205c0c 100644
--- a/setup.py
+++ b/setup.py
@@ -26,6 +26,8 @@
import os
import platform
+import re
+import subprocess
import sys
import ctypes
@@ -72,6 +74,27 @@ def _find_library(name):
target_lib = p
else:
target_lib = os.path.join(os.path.dirname(target_lib), p)
+ elif not target_lib:
+ # See https://bugs.python.org/issue9998
+ expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
+ cmd = ['ld', '-t']
+ libpath = os.environ.get('LD_LIBRARY_PATH')
+ if libpath:
+ for d in libpath.split(':'):
+ cmd.extend(['-L', d])
+ cmd.extend(['-o', os.devnull, '-l%s' % name])
+ try:
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True)
+ out, _ = p.communicate()
+ if hasattr(os, 'fsdecode'):
+ out = os.fsdecode(out)
+ res = re.search(expr, out)
+ if res:
+ target_lib = res.group(0)
+ except Exception:
+ pass # result will be None
# return absolute path to the library if found
return target_lib