diff --git a/pyproject.toml b/pyproject.toml index 2fa8382..1d6bdd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,9 @@ requires = [ "Cython>=3.0, <3.1", # TODO: simplify numpy requirement after numpy 1.26.0 final is released - "oldest-supported-numpy ; python_version < '3.12.0rc1'", - "numpy>=1.26.0b1 ; python_version >= '3.12.0rc1'", + "oldest-supported-numpy ; python_version < '3.9'", + "numpy>=1.25, <2.0 ; python_version >= '3.9' and python_version < '3.12.0rc1'", + "numpy>=1.26.0b1, <2.0; python_version >= '3.12.0rc1'", ] [project] @@ -24,6 +25,8 @@ dependencies = [ # match the absolute oldest version of numpy with *any* # level of support for our minimal Python requirement # https://github.com/scipy/oldest-supported-numpy/issues/76#issuecomment-1628865694 + + # after Python 3.8 is dropped, keep in sync with NPY_TARGET_VERSION (setup.py) "numpy>=1.17.3,<2.0", ] classifiers = [ diff --git a/setup.py b/setup.py index 74a5c4f..b2fca1b 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ import os +import sys import numpy as np from Cython.Build import cythonize @@ -16,7 +17,14 @@ else: std_libs = ["m"] -define_macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")] +define_macros = [ + ("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"), +] +if sys.version_info >= (3, 9): + # keep in sync with runtime requirements (pyproject.toml) + define_macros.append(("NPY_TARGET_VERSION", "NPY_1_18_API_VERSION")) +else: + pass extensions = [ Extension(