Skip to content

Commit 8d2be9a

Browse files
committed
[ci] fix import error for numpy 2.x
1 parent 96fe5b9 commit 8d2be9a

File tree

8 files changed

+25
-10
lines changed

8 files changed

+25
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- Copyright: (C) Qianqian Fang (2020-2025) <q.fang at neu.edu>
66
- Copyright: (C) Iotic Labs Ltd. (2016-2019) <vilnis.termanis at iotic-labs.com>
77
- License: Apache License, Version 2.0
8-
- Version: 0.5.1
8+
- Version: 0.5.2
99
- URL: https://pypi.org/project/bjdata/
1010
- Github: https://github.com/NeuroJSON/pybj
1111
- BJData Spec Version: [V1 Draft 3](https://neurojson.org/bjdata/draft3)

bjdata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from .encoder import EncoderException
4141
from .decoder import DecoderException
4242

43-
__version__ = "0.5.1"
43+
__version__ = "0.5.2"
4444

4545
__all__ = (
4646
"EXTENSION_ENABLED",

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
requires = [
33
"setuptools>=42",
44
"wheel",
5-
"numpy"
5+
"numpy>=2.0.0rc1; python_version>='3.9'",
6+
"numpy>=1.8.0; python_version<'3.9'"
67
]
78
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def build_extension(self, ext):
8080

8181
setup(
8282
name="bjdata",
83-
version="0.5.1",
83+
version="0.5.2",
8484
description="Binary JData and UBJSON encoder/decoder",
8585
long_description=load_description("README.md"),
8686
long_description_content_type="text/markdown",
@@ -134,6 +134,10 @@ def build_extension(self, ext):
134134
"Programming Language :: Python :: 3.7",
135135
"Programming Language :: Python :: 3.8",
136136
"Programming Language :: Python :: 3.9",
137+
"Programming Language :: Python :: 3.10",
138+
"Programming Language :: Python :: 3.11",
139+
"Programming Language :: Python :: 3.12",
140+
"Programming Language :: Python :: 3.13",
137141
"Topic :: Software Development :: Libraries",
138142
"Topic :: Software Development :: Libraries :: Python Modules",
139143
],

src/_bjdata.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
#include "common.h"
2121
#include "encoder.h"
2222
#include "decoder.h"
23-
24-
#define PY_ARRAY_UNIQUE_SYMBOL bjdata_numpy_array
25-
#define NPY_NO_DEPRECATED_API 0
26-
#include <numpy/arrayobject.h>
23+
#include "numpyapi.h"
2724

2825
/******************************************************************************/
2926

src/decoder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <Python.h>
1919
#include <bytesobject.h>
2020

21+
#define NO_IMPORT_ARRAY
22+
2123
#include "numpyapi.h"
2224
#include "common.h"
2325
#include "markers.h"

src/encoder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <bytesobject.h>
2020
#include <string.h>
2121

22+
#define NO_IMPORT_ARRAY
23+
2224
#include "numpyapi.h"
2325
#include "common.h"
2426
#include "markers.h"

src/numpyapi.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@
1717

1818
#pragma once
1919

20-
#define NO_IMPORT_ARRAY
2120
#define PY_ARRAY_UNIQUE_SYMBOL bjdata_numpy_array
22-
#define NPY_NO_DEPRECATED_API 0
21+
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
22+
#define NPY_TARGET_VERSION NPY_2_0_API_VERSION
2323
#include <numpy/arrayobject.h>
2424

2525
#if defined (__cplusplus)
2626
extern "C" {
2727
#endif
2828

29+
// Add compatibility macros
30+
#ifndef NPY_ARRAY_C_CONTIGUOUS
31+
#define NPY_ARRAY_C_CONTIGUOUS NPY_C_CONTIGUOUS
32+
#endif
33+
34+
#ifndef NPY_ARRAY_F_CONTIGUOUS
35+
#define NPY_ARRAY_F_CONTIGUOUS NPY_F_CONTIGUOUS
36+
#endif
37+
2938
// NumPy 2.0 compatibility layer
3039
#if NPY_API_VERSION >= 0x0000000f
3140

0 commit comments

Comments
 (0)