8000 BUG: Must fix `PyArray_RUNTIME_VERSION` backport logic · numpy/numpy@3a365b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a365b6

Browse files
committed
BUG: Must fix PyArray_RUNTIME_VERSION backport logic
1 parent 3026cd9 commit 3a365b6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

numpy/_core/include/numpy/npy_2_compat.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@
3232

3333
/*
3434
* Allow users to use `PyArray_RUNTIME_VERSION` when vendoring the file for
35-
* compilation with NumPy 1.x
35+
* compilation with NumPy 1.x.
36+
* Simply do not define when compiling with 2.x. It must be defined later
37+
* as it is set during `import_array()`.
3638
*/
37-
#ifndef PyArray_RUNTIME_VERSION
38-
/* IF we are compiling with NumPy 2, something is wrong: */
39-
#if NPY_ABI_VERSION >= 0x02000000
40-
#error "PyArray_RUNTIME_VERSION not defined, but `npy_2_compat.h` included"
41-
#endif
42-
/* Just hardcode it to the NPY_FEATURE_VERSION */
39+
#if !defined(PyArray_RUNTIME_VERSION) && NPY_ABI_VERSION < 0x02000000
40+
/*
41+
* If we are compiling with NumPy 1.x, PyArray_RUNTIME_VERSION so we
42+
* pretend the `PyArray_RUNTIME_VERSION` is `NPY_FEATURE_VERSION`.
43+
*/
4344
#define PyArray_RUNTIME_VERSION NPY_FEATURE_VERSION
4445
#endif
4546

0 commit comments

Comments
 (0)
0