From 1dc14d8f9436cb854b32cc8e76109eb127970f49 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 5 Apr 2024 11:18:23 +0100 Subject: [PATCH] MNT: Build agains Numpy v2 where possible Since it is not needed anymore with recent Numpy versions, and bump minimum required Numpy to 2.0.0rc1 in order to be able to build Numpy 2-compatible wheels --- pyproject.toml | 13 ++++++++++++- setup.py | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c3479b5c6..f27a28bf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,5 +3,16 @@ requires = [ "setuptools", "versioneer", "wheel", - "oldest-supported-numpy" + "oldest-supported-numpy ; python_version < '3.9'", + # Comments on numpy build requirement range: + # + # 1. >=2.0.x is the numpy requirement for wheel builds for distribution + # on PyPI - building against 2.x yields wheels that are also + # ABI-compatible with numpy 1.x at runtime. + # 2. Note that building against numpy 1.x works fine too - users and + # redistributors can do this by installing the numpy version they like + # and disabling build isolation. + # 3. The <2.3 upper bound is for matching the numpy deprecation policy, + # it should not be loosened + "numpy>=2.0.0rc1<2.3 ; python_version >= '3.9'", ] diff --git a/setup.py b/setup.py index c6d8fee4d..222a1b6e2 100644 --- a/setup.py +++ b/setup.py @@ -196,7 +196,10 @@ def get_long_description(): install_requires=["numpy"], extras_require={"doc": ["numpydoc", "sphinx", "gitpython"]}, cmdclass=cmdclass, - setup_requires=["numpy"], + setup_requires=[ + "oldest-supported-numpy ; python_version < '3.9'", + "numpy>=2.0.0rc1 ; python_version >= '3.9'" + ], ext_modules=prepare_modules(), zip_safe=False, )