Unverified Commit e291f503 authored by max yue's avatar max yue Committed by GitHub
Browse files

[Fix] Update libinfo.py (#1830)



* Update libinfo.py

fix `if search_path is list` error, and improve the code.

* change string format for compatibility with py35

change string format

* Update libinfo.py

* Update libinfo.py
Co-authored-by: default avatarMinjie Wang <wmjlyjemaine@gmail.com>
Co-authored-by: default avatarJinjing Zhou <VoVAllen@users.noreply.github.com>
Co-authored-by: default avatarQuan (Andy) Gan <coin2028@hotmail.com>
parent b8a4b446
......@@ -2,6 +2,7 @@
from __future__ import absolute_import
import sys
import os
import pathlib
def find_lib_path(name=None, search_path=None, optional=False):
......@@ -47,30 +48,32 @@ def find_lib_path(name=None, search_path=None, optional=False):
dll_path.append(install_lib_dir)
dll_path = [os.path.abspath(x) for x in dll_path]
if search_path is not None:
if search_path is list:
dll_path = dll_path + search_path
else:
if isinstance(search_path, (list, tuple, set)):
dll_path = dll_path + list(search_path)
elif isinstance(search_path, str):
dll_path.append(search_path)
if name is not None:
if isinstance(name, list):
lib_dll_path = []
for n in name:
lib_dll_path += [os.path.join(p, n) for p in dll_path]
else:
lib_dll_path = [os.path.join(p, name) for p in dll_path]
else:
raise ValueError("type(search_path)={} is invalid".format(type(search_path)))
dll_path = [str(x.absolute()) if isinstance(x, pathlib.Path)
else os.path.abspath(x) for x in dll_path]
if name is None:
if sys.platform.startswith('win32'):
lib_dll_path = [os.path.join(p, 'libdgl.dll') for p in dll_path] +\
[os.path.join(p, 'dgl.dll') for p in dll_path]
name = ['libdgl.dll', 'dgl.dll']
elif sys.platform.startswith('darwin'):
lib_dll_path = [os.path.join(p, 'libdgl.dylib') for p in dll_path]
name = 'libdgl.dylib'
else:
lib_dll_path = [os.path.join(p, 'libdgl.so') for p in dll_path]
name = 'libdgl.so'
if isinstance(name, str):
name = [name]
lib_dll_path = []
for n in name:
lib_dll_path += [os.path.join(p, n) for p in dll_path]
# try to find lib_dll_path
lib_found = [p for p in lib_dll_path if os.path.exists(p) and os.path.isfile(p)]
lib_found = [p for p in lib_dll_path if os.path.isfile(p)]
if not lib_found:
message = ('Cannot find the files.\n' +
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment