"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "ac2a9141fbf381e651e8c5fcea0c45c58822dd1d"
libpath.py 1.49 KB
Newer Older
wxchan's avatar
wxchan committed
1
# coding: utf-8
2
"""Find the path to LightGBM dynamic library files."""
wxchan's avatar
wxchan committed
3
import os
4
5
from platform import system

wxchan's avatar
wxchan committed
6
7
8

def find_lib_path():
    """Find the path to LightGBM library files.
9

wxchan's avatar
wxchan committed
10
11
    Returns
    -------
12
13
    lib_path: list of strings
       List of all found library paths to LightGBM.
wxchan's avatar
wxchan committed
14
    """
15
16
17
18
    if os.environ.get('LIGHTGBM_BUILD_DOC', False):
        # we don't need lib_lightgbm while building docs
        return []

wxchan's avatar
wxchan committed
19
    curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
20
21
    dll_path = [curr_path,
                os.path.join(curr_path, '../../'),
22
23
24
                os.path.join(curr_path, 'compile'),
                os.path.join(curr_path, '../compile'),
                os.path.join(curr_path, '../../lib/')]
25
    if system() in ('Windows', 'Microsoft'):
26
27
        dll_path.append(os.path.join(curr_path, '../compile/Release/'))
        dll_path.append(os.path.join(curr_path, '../compile/windows/x64/DLL/'))
Guolin Ke's avatar
Guolin Ke committed
28
        dll_path.append(os.path.join(curr_path, '../../Release/'))
29
        dll_path.append(os.path.join(curr_path, '../../windows/x64/DLL/'))
wxchan's avatar
wxchan committed
30
31
32
33
34
        dll_path = [os.path.join(p, 'lib_lightgbm.dll') for p in dll_path]
    else:
        dll_path = [os.path.join(p, 'lib_lightgbm.so') for p in dll_path]
    lib_path = [p for p in dll_path if os.path.exists(p) and os.path.isfile(p)]
    if not lib_path:
35
        dll_path = [os.path.realpath(p) for p in dll_path]
36
        raise Exception('Cannot find lightgbm library file in following paths:\n' + '\n'.join(dll_path))
wxchan's avatar
wxchan committed
37
    return lib_path