Find so with `ld -lname -Lpath`. It will search for files in LD_LIBRARY_PATH, but not in ldconfig.
(name)
| 268 | |
| 269 | # The following two methods come from https://github.com/python/cpython/blob/master/Lib/ctypes/util.py |
| 270 | def _use_ld(name): |
| 271 | """ |
| 272 | Find so with `ld -lname -Lpath`. |
| 273 | It will search for files in LD_LIBRARY_PATH, but not in ldconfig. |
| 274 | """ |
| 275 | cmd = "ld -t -l{} -o {}".format(name, os.devnull) |
| 276 | ld_lib_path = os.environ.get('LD_LIBRARY_PATH', '') |
| 277 | for d in ld_lib_path.split(':'): |
| 278 | cmd = cmd + " -L " + d |
| 279 | result, ret = subproc_call(cmd + '|| true') |
| 280 | expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) |
| 281 | res = re.search(expr, result.decode('utf-8')) |
| 282 | if res: |
| 283 | res = res.group(0) |
| 284 | if not os.path.isfile(res): |
| 285 | return None |
| 286 | return os.path.realpath(res) |
| 287 | |
| 288 | def _use_ldconfig(name): |
| 289 | """ |
no test coverage detected