summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Burke <tim.burke@gmail.com>2019-02-12 16:08:41 -0800
committerTim Burke <tim.burke@gmail.com>2019-02-13 14:38:35 -0800
commit2033d7b362f608a6f8740a81f5ebc75ed45a1022 (patch)
tree86bd4fe03caa3703aca3dee20c241213c715b81a
parent931c4e4559afeeaf1ea5867b1d44132626f2b575 (diff)
downloadpyeclib-2033d7b362f608a6f8740a81f5ebc75ed45a1022.tar.gz
Try harder to find liberasurecode
Allow the use of LD_LIBRARY_PATH when finding shared libraries; see https://bugs.python.org/issue9998 which was addressed in Python 3.6 Change-Id: I45f89152f94ca1bf9a8f097fbe69521892d285fe
-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