@@ -0,0 +1,51 @@
1+From 85991e0d7f0e631240f3f6233bd65d1128a66dec Mon Sep 17 00:00:00 2001
2+From: Frederik Rietdijk <fridh@fridh.nl>
3+Date: Thu, 14 Sep 2017 10:00:31 +0200
4+Subject: [PATCH] ctypes.util: support LD_LIBRARY_PATH
5+
6+Backports support for LD_LIBRARY_PATH from 3.6
7+---
8+ Lib/ctypes/util.py | 26 +++++++++++++++++++++++++-
9+ 1 file changed, 25 insertions(+), 1 deletion(-)
10+
11+diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
12+index 780cd5d21b..d7ac15070f 100644
13+--- a/Lib/ctypes/util.py
14++++ b/Lib/ctypes/util.py
15+@@ -181,8 +181,32 @@ elif os.name == "posix":
16+ def _findSoname_ldconfig(name):
17+ return None
18+
19++ def _findLib_ld(name):
20++ # See issue #9998 for why this is needed
21++ expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
22++ cmd = ['ld', '-t']
23++ libpath = os.environ.get('LD_LIBRARY_PATH')
24++ if libpath:
25++ for d in libpath.split(':'):
26++ cmd.extend(['-L', d])
27++ cmd.extend(['-o', os.devnull, '-l%s' % name])
28++ result = None
29++ try:
30++ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
31++ stderr=subprocess.PIPE,
32++ universal_newlines=True)
33++ out, _ = p.communicate()
34++ res = re.search(expr, os.fsdecode(out))
35++ if res:
36++ result = res.group(0)
37++ except Exception as e:
38++ pass # result will be None
39++ return result
40++
41+ def find_library(name):
42+- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
43++ # See issue #9998
44++ return _findSoname_ldconfig(name) or \
45++ _get_soname(_findLib_gcc(name) or _findLib_ld(name))
46+
47+ ################################################################
48+ # test code
49+--
50+2.14.1
51+