Skip to content

Commit

Permalink
Merge pull request #4948 from neutrinoceros/bld/remove_Cython_DEF
Browse files Browse the repository at this point in the history
BLD: fix compatibility with Cython 3.1
  • Loading branch information
chrishavlin authored Oct 3, 2024
2 parents 52c826f + 8a4003f commit 7956173
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
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

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

0 comments on commit 7956173

Please sign in to comment.