Commit c9fb514a authored by Tsukasa OMOTO's avatar Tsukasa OMOTO Committed by Guolin Ke
Browse files

docs: fix loading library (#492)

parent 152df4db
...@@ -19,14 +19,24 @@ ...@@ -19,14 +19,24 @@
# #
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath('../python-package'))
curr_path = os.path.dirname(os.path.realpath(__file__))
libpath = os.path.join(curr_path, '../python-package/')
sys.path.insert(0, libpath)
from recommonmark.parser import CommonMarkParser from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify from recommonmark.transform import AutoStructify
# -- mock out modules
from unittest.mock import Mock
MOCK_MODULES = ['numpy', 'scipy', 'scipy.sparse', 'sklearn', 'matplotlib', 'pandas', 'graphviz']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = Mock()
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
os.environ['LIGHTGBM_BUILD_DOC'] = '1'
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
# #
# needs_sphinx = '1.0' # needs_sphinx = '1.0'
......
...@@ -22,7 +22,7 @@ def _load_lib(): ...@@ -22,7 +22,7 @@ def _load_lib():
"""Load LightGBM Library.""" """Load LightGBM Library."""
lib_path = find_lib_path() lib_path = find_lib_path()
if len(lib_path) == 0: if len(lib_path) == 0:
raise Exception("cannot find LightGBM library") return None
lib = ctypes.cdll.LoadLibrary(lib_path[0]) lib = ctypes.cdll.LoadLibrary(lib_path[0])
lib.LGBM_GetLastError.restype = ctypes.c_char_p lib.LGBM_GetLastError.restype = ctypes.c_char_p
return lib return lib
......
...@@ -11,6 +11,10 @@ def find_lib_path(): ...@@ -11,6 +11,10 @@ def find_lib_path():
lib_path: list(string) lib_path: list(string)
List of all found library path to LightGBM List of all found library path to LightGBM
""" """
if os.environ.get('LIGHTGBM_BUILD_DOC', False):
# we don't need lib_lightgbm while building docs
return []
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
dll_path = [curr_path, os.path.join(curr_path, '../../lib/'), dll_path = [curr_path, os.path.join(curr_path, '../../lib/'),
os.path.join(curr_path, '../../'), os.path.join(curr_path, '../../'),
......
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