Fixes #31, add option numpy_version, skip_keras_test to the parser of build.py, add flag PRIVATE for the python bindings (#544)

* add option numpy_version to build against the installed numpy version and not 1.15.0 (hardcoded version number), default is still 1.15.0
* add option skip_keras_test to skip keras test even if keras is installed (still enabled by default)
disable unnecessary warnings about ubuntu
* enable option PRIVATE for the compilation of the Python bindings (settings recommended on pybind11 documentation)
* test on debian 9
This commit is contained in:
Xavier Dupré 2019-03-07 13:08:02 +01:00 committed by GitHub
parent 4635bcc624
commit b4ffcf8258
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 16 deletions

View file

@ -86,7 +86,7 @@ elseif (APPLE)
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH FALSE)
else()
target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${PYTHON_LIBRARY} ${ONNXRUNTIME_SO_LINK_FLAG} debug ${onnxruntime_EXTERNAL_LIBRARIES_DEBUG} optimized ${onnxruntime_EXTERNAL_LIBRARIES})
target_link_libraries(onnxruntime_pybind11_state PRIVATE ${onnxruntime_pybind11_state_libs} ${PYTHON_LIBRARY} ${ONNXRUNTIME_SO_LINK_FLAG} debug ${onnxruntime_EXTERNAL_LIBRARIES_DEBUG} optimized ${onnxruntime_EXTERNAL_LIBRARIES})
set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-Xlinker -rpath=\$ORIGIN")
endif()

View file

@ -47,9 +47,6 @@ def check_distro_info():
# warn the user ONNX Runtime may not work out of the box
__my_distro__ = __my_distro__.lower()
__my_distro_ver__ = __my_distro_ver__.lower()
if __my_distro__ != 'ubuntu' and __my_distro_ver__ != '16.04':
warnings.warn('Unsupported Linux distribution (%s-%s). ONNX Runtime supports Ubuntu 16.04 only.' % (__my_distro__, __my_distro_ver__))
elif __my_system__ == 'darwin':
__my_distro__ = __my_system__
__my_distro_ver__ = platform.release().lower()

View file

@ -79,6 +79,9 @@ Use the individual flags to only run the specified stages.
# Python bindings
parser.add_argument("--enable_pybind", action='store_true', help="Enable Python Bindings.")
parser.add_argument("--build_wheel", action='store_true', help="Build Python Wheel. ")
parser.add_argument("--numpy_version", default='1.15.0', help="Installs a specific version of numpy "
"before building the python binding.")
parser.add_argument("--skip-keras-test", action='store_true', help="Skip tests with Keras if keras is installed")
# C-Sharp bindings
parser.add_argument("--build_csharp", action='store_true', help="Build C#.Net DLL and NuGet package")
@ -195,8 +198,9 @@ def install_ubuntu_deps(args):
except Exception as e:
raise BuildError("Error setting up required APT packages. {}".format(str(e)))
def install_python_deps():
dep_packages = ['setuptools', 'wheel', 'numpy==1.15.0']
def install_python_deps(numpy_version=""):
dep_packages = ['setuptools', 'wheel']
dep_packages.append('numpy==%s' % numpy_version if numpy_version else 'numpy')
run_subprocess([sys.executable, '-m', 'pip', 'install', '--trusted-host', 'files.pythonhosted.org'] + dep_packages)
def check_md5(filename, expected_md5):
@ -465,15 +469,16 @@ def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs, enab
run_subprocess([os.path.join(cwd,'onnx_test_runner'), 'test_models'], cwd=cwd)
if config != 'Debug':
run_subprocess([sys.executable, 'onnx_backend_test_series.py'], cwd=cwd, dll_path=dll_path)
try:
import onnxmltools
import keras
onnxml_test = True
except ImportError:
warnings.warn("onnxmltools and keras are not installed. Following test cannot be run.")
onnxml_test = False
if onnxml_test:
run_subprocess([sys.executable, 'onnxruntime_test_python_keras.py'], cwd=cwd, dll_path=dll_path)
if not args.skip_keras_test:
try:
import onnxmltools
import keras
onnxml_test = True
except ImportError:
warnings.warn("onnxmltools and keras are not installed. Following test cannot be run.")
onnxml_test = False
if onnxml_test:
run_subprocess([sys.executable, 'onnxruntime_test_python_keras.py'], cwd=cwd, dll_path=dll_path)
def run_onnx_tests(build_dir, configs, onnx_test_data_dir, provider, enable_parallel_executor_test, num_parallel_models):
for config in configs:
@ -570,7 +575,7 @@ def main():
if not is_docker():
install_python_deps()
if (args.enable_pybind and is_windows()):
install_python_deps()
install_python_deps(args.numpy_version)
if (not args.skip_submodule_sync):
update_submodules(source_dir)