From 8f6cff3b37c686dcf2b94163b201b9396a17fd10 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Mon, 12 Feb 2024 13:40:30 -0600 Subject: [PATCH] Fix Cython 3 and Numpy 2 compatibility --- .github/workflows/ci.yaml | 2 +- pyproject.toml | 2 +- pyresample/ewa/_fornav.pyx | 1 + pyresample/ewa/_ll2cr.pyx | 2 ++ pyresample/gradient/_gradient_search.pyx | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 65b71d6b5..165e01075 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -47,7 +47,7 @@ jobs: shell: bash -l {0} run: | python -m pip install \ - -f https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com \ + --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/ \ --no-deps --pre --upgrade \ matplotlib \ numpy \ diff --git a/pyproject.toml b/pyproject.toml index 647781aa6..5e57fffce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "wheel", "numpy", "Cython", "versioneer-518"] +requires = ["setuptools", "wheel", "numpy", "Cython>=3", "versioneer-518"] build-backend = "setuptools.build_meta" [tool.ruff] diff --git a/pyresample/ewa/_fornav.pyx b/pyresample/ewa/_fornav.pyx index 53e33d3b0..6a57534b8 100644 --- a/pyresample/ewa/_fornav.pyx +++ b/pyresample/ewa/_fornav.pyx @@ -33,6 +33,7 @@ cimport cpython cimport cython cimport numpy +numpy.import_array() cdef extern from "_fornav_templates.h": ctypedef float weight_type diff --git a/pyresample/ewa/_ll2cr.pyx b/pyresample/ewa/_ll2cr.pyx index 9e0e8669e..c1810f7a7 100644 --- a/pyresample/ewa/_ll2cr.pyx +++ b/pyresample/ewa/_ll2cr.pyx @@ -28,6 +28,8 @@ from pyproj import Proj cimport cython cimport numpy +numpy.import_array() + # column and rows can only be doubles for now until the PROJ.4 is linked directly so float->double casting can be done # inside the loop ctypedef fused cr_dtype: diff --git a/pyresample/gradient/_gradient_search.pyx b/pyresample/gradient/_gradient_search.pyx index 23ae5c3b5..0f0e80dfb 100644 --- a/pyresample/gradient/_gradient_search.pyx +++ b/pyresample/gradient/_gradient_search.pyx @@ -30,6 +30,7 @@ ctypedef np.double_t DTYPE_t cimport cython from libc.math cimport fabs, isinf +np.import_array() @cython.boundscheck(False) @cython.wraparound(False)