diff --git a/requirements.txt b/requirements.txt index acfe76d53c3..0ebd994b1aa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ pip>=9.0.1 -numpy>1.16,<2.0 +numpy>1.16,<2.1 sympy>=1.9,<1.13 psutil>=5.1.0,<7.0 py-cpuinfo<10 diff --git a/setup.py b/setup.py index 5d22060ba09..82bb8717554 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,28 @@ import versioneer import os +import pkg_resources from setuptools import setup, find_packages + +def numpy_compat(required): + new_reqs = [r for r in required if "numpy" not in r and "sympy" not in r] + try: + sympy_version = pkg_resources.get_distribution("sympy").version + min_ver2 = pkg_resources.parse_version("1.12.1") + if pkg_resources.parse_version(sympy_version) < min_ver2: + new_reqs.append("numpy>1.16,<2.0") + else: + new_reqs.append("numpy>=2.0") + except pkg_resources.DistributionNotFound: + new_reqs.extend(["sympy>=1.12.1", "numpy>=2.0"]) + + return new_reqs + + with open('requirements.txt') as f: required = f.read().splitlines() + required = numpy_compat(required) with open('requirements-optional.txt') as f: optionals = f.read().splitlines()