From 7dd9bc4d78efef5964c8559217afbcc7c3aa417a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Wed, 13 Mar 2019 10:55:56 +0100 Subject: [PATCH] Restore changes removed by PR #571 (numpy version) (#603) add options numpy_version, skip-keras-test to build.py, gives more options to build onnxruntime --- tools/ci_build/build.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index ba59440385..1ed2728c02 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -81,6 +81,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") @@ -201,8 +204,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): @@ -477,15 +481,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: @@ -628,7 +633,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)