From 3c9b9c0d516b92d60f6ac2ac05a11ff2a1502eee Mon Sep 17 00:00:00 2001 From: Laramie Leavitt Date: Tue, 11 Jun 2024 10:33:12 -0700 Subject: [PATCH] Update tensorstore build to be compatible with numpy2 This requires: numpy>=2.0.0rc1 Fixes: https://github.com/google/tensorstore/issues/165 PiperOrigin-RevId: 642315379 Change-Id: Ie3fc8975929b0ba3bd3d996729b6e885dfcb9cf5 --- pyproject.toml | 2 +- python/tensorstore/numpy.h | 4 ++++ tools/ci/build_requirements.txt | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df0bb3d2f..3b626bccf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,5 +3,5 @@ requires = [ "setuptools>=30.3.0", "wheel", "setuptools_scm", - "numpy>=1.22.0", + "numpy>=2.0.0rc2", ] diff --git a/python/tensorstore/numpy.h b/python/tensorstore/numpy.h index b6ad6ee8f..b47ea187f 100644 --- a/python/tensorstore/numpy.h +++ b/python/tensorstore/numpy.h @@ -42,6 +42,10 @@ #error "Numpy cannot be included before numpy.h." #endif +// Require NumPy >= 1.22 for NPY_ARRAY_ENSURENOCOPY. +// https://numpy.org/devdocs/dev/depending_on_numpy.html#build-time-dependency +#define NPY_TARGET_VERSION NPY_1_22_API_VERSION + // Disallow Numpy 1.7 deprecated symbols. #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION diff --git a/tools/ci/build_requirements.txt b/tools/ci/build_requirements.txt index f6597db7d..e8d32140c 100644 --- a/tools/ci/build_requirements.txt +++ b/tools/ci/build_requirements.txt @@ -1,2 +1,2 @@ -r ../../third_party/pypa/wheel_requirements_frozen.txt -numpy>=1.22.0 +numpy>=2.0.0rc2