From 1fa69866563f99edce9dc4be8b17ab835928de9b Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Wed, 23 Jun 2021 14:08:37 -0700 Subject: [PATCH] Chang how numpy version is handled. (#8130) Numpy has binary compatibility, which means "binaries compiled against a given version of NumPy will still run correctly with newer NumPy versions, but not with older versions." So, if an onnx runtime package was built with numpy version A, then at run time it requires numpy version >=A. In this change, we read numpy version from the installed packages at build time, to avoid manually keeping the build time/runtime consistency. --- cmake/CMakeLists.txt | 8 ++++++++ requirements.txt | 3 --- requirements.txt.in | 3 +++ setup.py | 8 -------- 4 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 requirements.txt create mode 100644 requirements.txt.in diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index e1da1eccef..456765a16a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1372,6 +1372,14 @@ if (onnxruntime_USE_VITISAI) endif() configure_file(onnxruntime_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime_config.h) +if(WIN32) + configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/Debug/requirements.txt) + configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/Release/requirements.txt) + configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/requirements.txt) + configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel/requirements.txt) +else() + configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/requirements.txt) +endif() if (onnxruntime_USE_CUDA) #The following 6 lines are copied from https://gitlab.kitware.com/cmake/cmake/issues/17559 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ebdf9acad1..0000000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -numpy >= 1.16.6 -protobuf -flatbuffers diff --git a/requirements.txt.in b/requirements.txt.in new file mode 100644 index 0000000000..1040bd79f5 --- /dev/null +++ b/requirements.txt.in @@ -0,0 +1,3 @@ +numpy >= @Python_NumPy_VERSION@ +protobuf +flatbuffers diff --git a/setup.py b/setup.py index 8a015ae41a..ae500f6709 100644 --- a/setup.py +++ b/setup.py @@ -396,14 +396,6 @@ with open(requirements_path) as f: install_requires = f.read().splitlines() -if is_manylinux: - AUDITWHEEL_PLAT = environ.get('AUDITWHEEL_PLAT', None) - if AUDITWHEEL_PLAT == 'manylinux2014_aarch64': - for i in range(len(install_requires)): - req = install_requires[i] - if req.startswith("numpy"): - install_requires[i] = "numpy >= 1.19.5" - if enable_training: def save_build_and_package_info(package_name, version_number, cuda_version):