From 6262fd6e9f6ac2295d8f58228b86d41cef539228 Mon Sep 17 00:00:00 2001 From: q-posev Date: Thu, 30 Sep 2021 17:23:43 +0200 Subject: [PATCH] pin numpy versions to avoid RuntimeError when importing trexio --- docker/build_manylinux_wheels.sh | 9 ++++++++- python/pyproject.toml | 15 ++++++++++++++- python/requirements.txt | 2 +- python/setup.py | 3 +-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docker/build_manylinux_wheels.sh b/docker/build_manylinux_wheels.sh index d8dd280..d282eca 100755 --- a/docker/build_manylinux_wheels.sh +++ b/docker/build_manylinux_wheels.sh @@ -58,7 +58,14 @@ function build_wheel_for_py() # upgrade pip, otherwise it complains that manylinux wheel is "...not supported wheel on this platform" pip install --upgrade pip # install dependencies needed to build manylinux wheel - pip install --upgrade setuptools wheel auditwheel numpy + pip install --upgrade setuptools wheel auditwheel + if [ ${PYVERSION} -eq 36 ] || [ ${PYVERSION} -eq 37 ]; then + pip install numpy==1.17.3 + elif [ ${PYVERSION} -eq 38 ]; then + pip install numpy==1.18.3 + else + pip install numpy==1.19.3 + fi # set an environment variable needed to locate numpy header files source tools/set_NUMPY_INCLUDEDIR.sh diff --git a/python/pyproject.toml b/python/pyproject.toml index fa03e4c..f8ac16d 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -2,6 +2,19 @@ requires = [ "setuptools>=42", "wheel", - "pkgconfig" + "pkgconfig", + # Numpy requirements for different OS/architectures + # Copied from https://github.com/scipy/scipy/blob/master/pyproject.toml (which is also licensed under BSD) + "numpy==1.17.3; python_version=='3.6' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='aarch64'", + "numpy==1.17.3; python_version=='3.7' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='aarch64'", + "numpy==1.18.3; python_version=='3.8' and (platform_machine!='arm64' or platform_system!='Darwin') and platform_machine!='aarch64'", + "numpy==1.19.3; python_version>='3.9' and (platform_machine!='arm64' or platform_system!='Darwin')", + # Aarch64(Python 3.9 requirements are the same as AMD64) + "numpy==1.19.2; python_version=='3.6' and platform_machine=='aarch64'", + "numpy==1.19.2; python_version=='3.7' and platform_machine=='aarch64'", + "numpy==1.19.2; python_version=='3.8' and platform_machine=='aarch64'", + # Darwin Arm64 + "numpy>=1.20.0; python_version=='3.8' and platform_machine=='arm64' and platform_system=='Darwin'", + "numpy>=1.20.0; python_version=='3.9' and platform_machine=='arm64' and platform_system=='Darwin'" ] build-backend = "setuptools.build_meta" diff --git a/python/requirements.txt b/python/requirements.txt index e7bbedf..a370234 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,3 +1,3 @@ setuptools>=42 pkgconfig -numpy +numpy>=1.17.3 diff --git a/python/setup.py b/python/setup.py index 839b957..5ead098 100644 --- a/python/setup.py +++ b/python/setup.py @@ -113,7 +113,6 @@ setup(name = 'trexio', "Operating System :: MacOS" ], python_requires = ">=3.6", - setup_requires = ['numpy', 'pkgconfig'], - install_requires = ['numpy'] + install_requires = ['numpy>=1.17.3'] )