Skip to content

Commit

Permalink
docs: fix loading library (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
henry0312 authored and guolinke committed May 5, 2017
1 parent 152df4d commit c9fb514
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@
#
import os
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.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 ------------------------------------------------

os.environ['LIGHTGBM_BUILD_DOC'] = '1'

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
Expand Down
2 changes: 1 addition & 1 deletion python-package/lightgbm/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _load_lib():
"""Load LightGBM Library."""
lib_path = find_lib_path()
if len(lib_path) == 0:
raise Exception("cannot find LightGBM library")
return None
lib = ctypes.cdll.LoadLibrary(lib_path[0])
lib.LGBM_GetLastError.restype = ctypes.c_char_p
return lib
Expand Down
4 changes: 4 additions & 0 deletions python-package/lightgbm/libpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def find_lib_path():
lib_path: list(string)
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__)))
dll_path = [curr_path, os.path.join(curr_path, '../../lib/'),
os.path.join(curr_path, '../../'),
Expand Down

0 comments on commit c9fb514

Please sign in to comment.