"...git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "3f54429cbf84c3d3f18077a242245763a91df477"
libpath.py 1.42 KB
Newer Older
wxchan's avatar
wxchan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
# coding: utf-8
"""Find the path to lightgbm dynamic library files."""
import os
import sys


def find_lib_path():
    """Find the path to LightGBM library files.
    Returns
    -------
    lib_path: list(string)
       List of all found library path to LightGBM
    """
14
15
16
17
    if os.environ.get('LIGHTGBM_BUILD_DOC', False):
        # we don't need lib_lightgbm while building docs
        return []

wxchan's avatar
wxchan committed
18
    curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
19
20
21
22
    dll_path = [curr_path, os.path.join(curr_path, '../../'),
                os.path.join(curr_path, 'compile'),
                os.path.join(curr_path, '../compile'),
                os.path.join(curr_path, '../../lib/')]
wxchan's avatar
wxchan committed
23
    if os.name == 'nt':
24
25
        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
26
        dll_path.append(os.path.join(curr_path, '../../Release/'))
27
        dll_path.append(os.path.join(curr_path, '../../windows/x64/DLL/'))
wxchan's avatar
wxchan committed
28
29
30
31
32
        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:
33
        dll_path = [os.path.realpath(p) for p in dll_path]
34
        raise Exception('Cannot find lightgbm library in following paths: ' + '\n'.join(dll_path))
wxchan's avatar
wxchan committed
35
    return lib_path