Skip to content

Commit 52c153d

Browse files
committed
Limited API only
1 parent bf6d3c0 commit 52c153d

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

python/kvikio/kvikio/_lib/arr.pyx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# Copyright (c) 2020-2024, NVIDIA CORPORATION. All rights reserved.
1+
# Copyright (c) 2020-2025, NVIDIA CORPORATION. All rights reserved.
22
# See file LICENSE for terms.
33

44
# cython: language_level=3
55

66

7-
from cpython.buffer cimport PyBuffer_IsContiguous
7+
from cpython.buffer cimport (
8+
PyBUF_FULL_RO,
9+
PyBuffer_IsContiguous,
10+
PyBuffer_Release,
11+
PyObject_GetBuffer,
12+
)
813
from cpython.mem cimport PyMem_Free, PyMem_Malloc
9-
from cpython.memoryview cimport PyMemoryView_FromObject, PyMemoryView_GET_BUFFER
1014
from cpython.ref cimport Py_INCREF
11-
from cpython.tuple cimport PyTuple_New, PyTuple_SET_ITEM
15+
from cpython.tuple cimport PyTuple_New, PyTuple_SetItem
1216
from cython cimport auto_pickle, boundscheck, initializedcheck, nonecheck, wraparound
1317
from cython.view cimport array
1418
from libc.stdint cimport uintptr_t
@@ -75,7 +79,7 @@ cdef class Array:
7579
def __cinit__(self, obj):
7680
cdef dict iface = getattr(obj, "__cuda_array_interface__", None)
7781
self.cuda = (iface is not None)
78-
cdef const Py_buffer* pybuf
82+
cdef Py_buffer* pybuf
7983
cdef str typestr
8084
cdef tuple data, shape, strides
8185
cdef Py_ssize_t i
@@ -125,8 +129,7 @@ cdef class Array:
125129
self.shape_mv = None
126130
self.strides_mv = None
127131
else:
128-
mv = PyMemoryView_FromObject(obj)
129-
pybuf = PyMemoryView_GET_BUFFER(mv)
132+
PyObject_GetBuffer(obj, pybuf, PyBUF_FULL_RO)
130133

131134
if pybuf.suboffsets != NULL:
132135
raise NotImplementedError("Suboffsets are not supported")
@@ -156,6 +159,7 @@ cdef class Array:
156159
else:
157160
self.shape_mv = None
158161
self.strides_mv = None
162+
PyBuffer_Release(pybuf)
159163

160164
cpdef bint _c_contiguous(self):
161165
return _c_contiguous(
@@ -203,7 +207,7 @@ cdef class Array:
203207
for i in range(self.ndim):
204208
o = self.shape_mv[i]
205209
Py_INCREF(o)
206-
PyTuple_SET_ITEM(shape, i, o)
210+
PyTuple_SetItem(shape, i, o)
207211
return shape
208212

209213
@property
@@ -219,13 +223,13 @@ cdef class Array:
219223
for i from self.ndim > i >= 0 by 1:
220224
o = self.strides_mv[i]
221225
Py_INCREF(o)
222-
PyTuple_SET_ITEM(strides, i, o)
226+
PyTuple_SetItem(strides, i, o)
223227
else:
224228
s = self.itemsize
225229
for i from self.ndim > i >= 0 by 1:
226230
o = s
227231
Py_INCREF(o)
228-
PyTuple_SET_ITEM(strides, i, o)
232+
PyTuple_SetItem(strides, i, o)
229233
s *= self.shape_mv[i]
230234
return strides
231235

python/kvikio/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authors = [
1919
license = { text = "Apache 2.0" }
2020
requires-python = ">=3.10"
2121
dependencies = [
22-
"cupy-cuda11x>=12.0.0",
22+
"cupy-cuda12x>=12.0.0",
2323
"libkvikio==25.6.*,>=0.0.0a0",
2424
"numcodecs !=0.12.0",
2525
"numpy>=1.23,<3.0a0",
@@ -41,7 +41,7 @@ classifiers = [
4141
[project.optional-dependencies]
4242
test = [
4343
"boto3>=1.21.21",
44-
"cuda-python>=11.8.5,<12.0a0",
44+
"cuda-python>=12.6.2,<13.0a0",
4545
"moto[server]>=4.0.8",
4646
"pytest",
4747
"pytest-asyncio",

0 commit comments

Comments
 (0)