Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin Cython < 3.0 #15

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.7, 3.8, 3.9]
python-version: ['3.9', '3.10', '3.11']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
22 changes: 5 additions & 17 deletions cyarray/carray.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,6 @@ cdef extern from "numpy/arrayobject.h":
cdef extern from "stdlib.h":
void *memcpy(void *dst, void *src, long n) nogil


# Cython>= 3.0 now disallows relpacing the guts of a numpy array.
# Workaround: Thanks https://github.com/rainwoodman/pandas/blob/05d3fe2402e4563124e7060837ded7513ab5bca7/pandas/_libs/reduction.pyx#L27 # noqa: E501
# FIXME: FIND A CLEANER SOLUTION
cdef extern from *:
"""
static void PyArray_SET_DATA(PyArrayObject *arr, char * data) {
arr->data = data;
}
"""
void PyArray_SET_DATA(np.ndarray arr, char * data) nogil

# numpy module initialization call
_import_array()

Expand Down Expand Up @@ -463,7 +451,7 @@ cdef class IntArray(BaseArray):
if self._old_data != NULL:
self.data = self._old_data
self._old_data = NULL
PyArray_SET_DATA(self._npy_array, <char *>self.data)
self._npy_array.data = <char *>self.data

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down Expand Up @@ -968,7 +956,7 @@ cdef class UIntArray(BaseArray):
if self._old_data != NULL:
self.data = self._old_data
self._old_data = NULL
PyArray_SET_DATA(self._npy_array, <char *>self.data)
self._npy_array.data = <char *>self.data

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down Expand Up @@ -1473,7 +1461,7 @@ cdef class LongArray(BaseArray):
if self._old_data != NULL:
self.data = self._old_data
self._old_data = NULL
PyArray_SET_DATA(self._npy_array, <char *>self.data)
self._npy_array.data = <char *>self.data

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down Expand Up @@ -1978,7 +1966,7 @@ cdef class FloatArray(BaseArray):
if self._old_data != NULL:
self.data = self._old_data
self._old_data = NULL
PyArray_SET_DATA(self._npy_array, <char *>self.data)
self._npy_array.data = <char *>self.data

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down Expand Up @@ -2483,7 +2471,7 @@ cdef class DoubleArray(BaseArray):
if self._old_data != NULL:
self.data = self._old_data
self._old_data = NULL
PyArray_SET_DATA(self._npy_array, <char *>self.data)
self._npy_array.data = <char *>self.data

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down
14 changes: 1 addition & 13 deletions cyarray/carray.pyx.mako
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,6 @@ cdef extern from "numpy/arrayobject.h":
cdef extern from "stdlib.h":
void *memcpy(void *dst, void *src, long n) nogil


# Cython>= 3.0 now disallows relpacing the guts of a numpy array.
# Workaround: Thanks https://github.com/rainwoodman/pandas/blob/05d3fe2402e4563124e7060837ded7513ab5bca7/pandas/_libs/reduction.pyx#L27 # noqa: E501
# FIXME: FIND A CLEANER SOLUTION
cdef extern from *:
"""
static void PyArray_SET_DATA(PyArrayObject *arr, char * data) {
arr->data = data;
}
"""
void PyArray_SET_DATA(np.ndarray arr, char * data) nogil

# numpy module initialization call
_import_array()

Expand Down Expand Up @@ -475,7 +463,7 @@ cdef class ${CLASSNAME}(BaseArray):
if self._old_data != NULL:
self.data = self._old_data
self._old_data = NULL
PyArray_SET_DATA(self._npy_array, <char *>self.data)
self._npy_array.data = <char *>self.data

cdef void c_resize(self, long size) nogil:
cdef PyArrayObject* arr = <PyArrayObject*>self._npy_array
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ requires = [
"wheel>=0.29.0",
"setuptools>=42.0.0",
"oldest-supported-numpy",
"Cython>=0.20",
"Cython<3.0",
"mako"
]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cython>=0.20
Cython<3.0
setuptools>=6.0
numpy
mako
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def setup_package():

# The requirements.
install_requires = [
'numpy', 'mako', 'Cython>=0.20', 'setuptools>=6.0'
'numpy', 'mako', 'Cython<3.0', 'setuptools>=6.0'
]
tests_require = ["pytest"]
docs_require = ["sphinx"]
Expand Down