From 569ff74dd4ca3942bf31724602788a5d388e73bb Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Wed, 17 Aug 2016 16:20:07 +0100 Subject: Closes #9998: Allowed find_library to search additional locations for libraries. --- Lib/ctypes/util.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'Lib/ctypes/util.py') diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index e25a886a05..f5c6b266b6 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -285,8 +285,32 @@ elif os.name == "posix": except OSError: pass + def _findLib_ld(name): + # See issue #9998 for why this is needed + 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]) + result = None + try: + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True) + out, _ = p.communicate() + res = re.search(expr, os.fsdecode(out)) + if res: + result = res.group(0) + except Exception as e: + pass # result will be None + return result + def find_library(name): - return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name)) + # See issue #9998 + return _findSoname_ldconfig(name) or \ + _get_soname(_findLib_gcc(name) or _findLib_ld(name)) ################################################################ # test code -- cgit v1.2.1 From bb0ec1fc07628252f17d66a58a4a4b3654e571c3 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Mon, 5 Sep 2016 15:11:23 -0700 Subject: Issue #27355: Removed support for Windows CE. It was never finished, and Windows CE is no longer a relevant platform for Python. --- Lib/ctypes/util.py | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'Lib/ctypes/util.py') diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index f5c6b266b6..339ae8aa8a 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -67,16 +67,6 @@ if os.name == "nt": return fname return None -if os.name == "ce": - # search path according to MSDN: - # - absolute path specified by filename - # - The .exe launch directory - # - the Windows directory - # - ROM dll files (where are they?) - # - OEM specified search path: HKLM\Loader\SystemPath - def find_library(name): - return name - if os.name == "posix" and sys.platform == "darwin": from ctypes.macholib.dyld import dyld_find as _dyld_find def find_library(name): -- cgit v1.2.1