(name)
return os.path.realpath(res.group(1))
Find full path of a shared library.

    Searches for the full path of a shared library. On Posix operating systems
    other than MacOS, this function checks the directories listed in
    LD_LIBRARY_PATH (if any) and in the ld.so cache.

    Parameter
    ---------
    name : str
        Link name of library, e.g., cublas for libcublas.so.*.

    Returns
    -------
    path : str
        Full path to library.

    Notes
    -----
    Code adapted from ctypes.util module. Doesn't check whether the
    architectures of libraries found in LD_LIBRARY_PATH directories conform
    to that of the machine.
Find full path of a shared library.
Find full path of a shared library .
def find_lib_path(name):
    """
    Find full path of a shared library.

    Searches for the full path of a shared library. On Posix operating systems
    other than MacOS, this function checks the directories listed in
    LD_LIBRARY_PATH (if any) and in the ld.so cache.

    Parameter
    ---------
    name : str
        Link name of library, e.g., cublas for libcublas.so.*.

    Returns
    -------
    path : str
        Full path to library.

    Notes
    -----
    Code adapted from ctypes.util module. Doesn't check whether the
    architectures of libraries found in LD_LIBRARY_PATH directories conform
    to that of the machine.
    """

    if sys.platform == 'win32':
        return ctypes.util.find_library(name)

    # MacOS has no ldconfig:
    if sys.platform == 'darwin':
        from ctypes.macholib.dyld import dyld_find as _dyld_find
        possible = ['lib%s.dylib' % name,
                    '%s.dylib' % name,
                    '%s.framework/%s' % (name, name)]
        for name in possible:
            try:
                return _dyld_find(name)
            except ValueError:
                continue
        return None

    # First, check the directories in LD_LIBRARY_PATH:
    expr = r'\s+(lib%s\.[^\s]+)\s+\-\>' % re.escape(name)
    for dir_path in filter(len,
            os.environ.get('LD_LIBRARY_PATH', '').split(':')):
        f = os.popen('/sbin/ldconfig -Nnv %s 2>/dev/null' % dir_path)
        try:
            data = f.read()
        finally:
            f.close()
        res = re.search(expr, data)
        if res:
            return os.path.join(dir_path, res.group(1))

    # Next, check the ld.so cache:
    uname = os.uname()[4]
    if uname.startswith("arm"):
        uname = "arm"
    if struct.calcsize('l') == 4:
        machine = uname + '-32'
    else:
        machine = uname + '-64'
    mach_map = {
        'x86_64-64': 'libc6,x86-64',
        'ppc64-64': 'libc6,64bit',
        'sparc64-64': 'libc6,64bit',
        's390x-64': 'libc6,64bit',
        'ia64-64': 'libc6,IA-64',
        'arm-32': 'libc6(,hard-float)?',
        }
    abi_type = mach_map.get(machine, 'libc6')
    expr = r'\s+lib%s\.[^\s]+\s+\(%s.*\=\>\s(.+)' % (re.escape(name), abi_type)
    f = os.popen('/sbin/ldconfig -p 2>/dev/null')
    try:
        data = f.read()
    finally:
        f.close()
    res = re.search(expr, data)
    if not res:
        return None

    # Follow symbolic links to the actual file:
    return os.path.realpath(res.group(1))
def find_lib_path ( name ) : if sys . platform == 'win32' : return ctypes . util . find_library ( name ) # MacOS has no ldconfig: if sys . platform == 'darwin' : from ctypes . macholib . dyld import dyld_find as _dyld_find possible = [ 'lib%s.dylib' % name , '%s.dylib' % name , '%s.framework/%s' % ( name , name ) ] for name in possible : try : return _dyld_find ( name ) except ValueError : continue return None # First, check the directories in LD_LIBRARY_PATH: expr = r'\s+(lib%s\.[^\s]+)\s+\-\>' % re . escape ( name ) for dir_path in filter ( len , os . environ . get ( 'LD_LIBRARY_PATH' , '' ) . split ( ':' ) ) : f = os . popen ( '/sbin/ldconfig -Nnv %s 2>/dev/null' % dir_path ) try : data = f . read ( ) finally : f . close ( ) res = re . search ( expr , data ) if res : return os . path . join ( dir_path , res . group ( 1 ) ) # Next, check the ld.so cache: uname = os . uname ( ) [ 4 ] if uname . startswith ( "arm" ) : uname = "arm" if struct . calcsize ( 'l' ) == 4 : machine = uname + '-32' else : machine = uname + '-64' mach_map = { 'x86_64-64' : 'libc6,x86-64' , 'ppc64-64' : 'libc6,64bit' , 'sparc64-64' : 'libc6,64bit' , 's390x-64' : 'libc6,64bit' , 'ia64-64' : 'libc6,IA-64' , 'arm-32' : 'libc6(,hard-float)?' , } abi_type = mach_map . get ( machine , 'libc6' ) expr = r'\s+lib%s\.[^\s]+\s+\(%s.*\=\>\s(.+)' % ( re . escape ( name ) , abi_type ) f = os . popen ( '/sbin/ldconfig -p 2>/dev/null' ) try : data = f . read ( ) finally : f . close ( ) res = re . search ( expr , data ) if not res : return None # Follow symbolic links to the actual file: return os . path . realpath ( res . group ( 1 ) )