11# coding: utf-8
22"""Information about nnvm."""
33from __future__ import absolute_import
4+ import sys
45import os
56import platform
67
8+ if sys .version_info [0 ] == 3 :
9+ import builtins as __builtin__
10+ else :
11+ import __builtin__
12+
713def find_lib_path ():
814 """Find NNNet dynamic library files.
915
@@ -12,10 +18,19 @@ def find_lib_path():
1218 lib_path : list(string)
1319 List of all found path to the libraries
1420 """
15- curr_path = os .path .dirname (os .path .abspath (os .path .expanduser (__file__ )))
16- api_path = os .path .join (curr_path , '../../lib/' )
17- cmake_build_path = os .path .join (curr_path , '../../build/Release/' )
18- dll_path = [curr_path , api_path , cmake_build_path ]
21+ if hasattr (__builtin__ , "NNVM_BASE_PATH" ):
22+ base_path = __builtin__ .NNVM_BASE_PATH
23+ else :
24+ base_path = os .path .dirname (os .path .abspath (os .path .expanduser (__file__ )))
25+
26+ if hasattr (__builtin__ , "NNVM_LIBRARY_NAME" ):
27+ lib_name = __builtin__ .NNVM_LIBRARY_NAME
28+ else :
29+ lib_name = "libnnvm_example"
30+
31+ api_path = os .path .join (base_path , '../../lib/' )
32+ cmake_build_path = os .path .join (base_path , '../../build/Release/' )
33+ dll_path = [base_path , api_path , cmake_build_path ]
1934 if os .name == 'nt' :
2035 vs_configuration = 'Release'
2136 if platform .architecture ()[0 ] == '64bit' :
@@ -27,9 +42,9 @@ def find_lib_path():
2742 elif os .name == "posix" and os .environ .get ('LD_LIBRARY_PATH' , None ):
2843 dll_path .extend ([p .strip () for p in os .environ ['LD_LIBRARY_PATH' ].split (":" )])
2944 if os .name == 'nt' :
30- dll_path = [os .path .join (p , 'libnnvm_example .dll' ) for p in dll_path ]
45+ dll_path = [os .path .join (p , '%s .dll' % lib_name ) for p in dll_path ]
3146 else :
32- dll_path = [os .path .join (p , 'libnnvm_example .so' ) for p in dll_path ]
47+ dll_path = [os .path .join (p , '%s .so' % lib_name ) for p in dll_path ]
3348 lib_path = [p for p in dll_path if os .path .exists (p ) and os .path .isfile (p )]
3449 if len (lib_path ) == 0 :
3550 raise RuntimeError ('Cannot find the files.\n ' +
0 commit comments