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

BLD: fix compatibility with Cython 3.1 #4948

Merged
merged 4 commits into from
Oct 3, 2024
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/bleeding-edge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python -m pip install --pre --only-binary ":all:" numpy matplotlib \
python -m pip install --pre --only-binary ":all:" numpy matplotlib Cython \
--extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
python -m pip install --pre ewah-bool-utils Cython
python -m pip install --pre ewah-bool-utils
python -m pip install git+https://github.com/yt-project/unyt.git
python -m pip install --pre pytest PyYAML

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ jobs:

# keep in sync with pyproject.toml
run: |
python -m pip install "Cython>=3.0.3, <3.1"
python -m pip install numpy>=1.25
python -m pip install ewah-bool-utils>=1.0.2
python -m pip install --upgrade wheel
python -m pip install Cython>=3.0.3
python -m pip install numpy>=2.0.0
python -m pip install ewah-bool-utils>=1.2.0
python -m pip install --upgrade setuptools
- name: build yt
shell: bash
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# keep in sync with .github/workflows/wheels.yaml
requires = [
"setuptools>=61.2",

# for the upper pin in Cython
# see https://github.com/yt-project/yt/issues/4044
"Cython>=3.0.3, <3.1",
"Cython>=3.0.3",
"numpy>=2.0.0",
"ewah-bool-utils>=1.2.0",
]
Expand Down
3 changes: 2 additions & 1 deletion yt/geometry/particle_deposit.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import numpy as np
cimport cython
from libc.math cimport sqrt
from libc.stdlib cimport free, malloc
from numpy.math cimport PI as NPY_PI

from yt.utilities.lib.fp_utils cimport *

from .oct_container cimport Oct, OctreeContainer

cdef extern from "numpy/npy_math.h":
double NPY_PI
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To see why this change was needed, see https://cython.readthedocs.io/en/latest/src/changes.html#other-changes

The previously shipped NumPy C-API declarations (cimport numpy) were removed. NumPy has been providing version specific declarations for several versions now. (Github issue #5842)


cdef extern from "platform_dep.h":
void *alloca(int)
Expand Down
17 changes: 11 additions & 6 deletions yt/utilities/lib/geometry_utils.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ cimport numpy as np
from libc.float cimport DBL_MANT_DIG
from libc.math cimport frexp, ldexp, sqrt

DEF ORDER_MAX=20
DEF INDEX_MAX_64=2097151
# TODO: Handle error for indices past max
DEF XSHIFT=2
DEF YSHIFT=1
DEF ZSHIFT=0
cdef enum:
ORDER_MAX=20

cdef enum:
# TODO: Handle error for indices past max
INDEX_MAX_64=2097151

cdef enum:
XSHIFT=2
YSHIFT=1
ZSHIFT=0

@cython.cdivision(True)
@cython.boundscheck(False)
Expand Down
6 changes: 0 additions & 6 deletions yt/utilities/lib/geometry_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ from yt.utilities.exceptions import YTDomainOverflow

from yt.utilities.lib.vec3_ops cimport L2_norm, cross, dot, subtract

DEF ORDER_MAX=20
DEF INDEX_MAX_64=2097151
DEF XSHIFT=2
DEF YSHIFT=1
DEF ZSHIFT=0

cdef extern from "math.h":
double exp(double x) noexcept nogil
float expf(float x) noexcept nogil
Expand Down
3 changes: 2 additions & 1 deletion yt/utilities/lib/image_samplers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ cimport numpy as np
from .partitioned_grid cimport PartitionedGrid
from .volume_container cimport VolumeContainer

DEF Nch = 4
cdef enum:
Nch = 4

# NOTE: We don't want to import the field_interpolator_tables here, as it
# breaks a bunch of C++ interop. Maybe some day it won't. So, we just forward
Expand Down
2 changes: 0 additions & 2 deletions yt/utilities/lib/image_samplers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ from ._octree_raytracing cimport RayInfo, _OctreeRayTracing
cdef extern from "platform_dep.h":
long int lrint(double x) noexcept nogil

DEF Nch = 4

from cython.parallel import parallel, prange

from cpython.exc cimport PyErr_CheckSignals
Expand Down
Loading