Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 0 additions & 3 deletions onnxruntime/python/onnxruntime_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
29 changes: 17 additions & 12 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def parse_arguments():
# 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")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down