MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / _use_ld

Function _use_ld

tensorpack/utils/utils.py:270–286  ·  view source on GitHub ↗

Find so with `ld -lname -Lpath`. It will search for files in LD_LIBRARY_PATH, but not in ldconfig.

(name)

Source from the content-addressed store, hash-verified

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 """

Callers 1

find_library_full_pathFunction · 0.85

Calls 4

subproc_callFunction · 0.85
formatMethod · 0.80
groupMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected