Skip to content

Commit 31f782a

Browse files
committed
Set c_api_binop_methods compiler directive to True
This retains Cython 0.x behavior for arithmetic operators for Cython >= 3.0.0.
1 parent 91cd0d0 commit 31f782a

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ since version 1.6.2 release
22
===========================
33
* add support for formats without separators in strptime (e.g. '20200229', issue #301).
44
This required removing support for > 4 digit years.
5+
* set the c_api_binop_methods compiler directive to True to retain Cython 0.x
6+
behavior for arithmetic operators for Cython >= 3.0.0 (issue #271).
57

68
version 1.6.2 (release tag v1.6.2rel)
79
=====================================

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools>=41.2", "cython", "wheel", "oldest-supported-numpy"]
2+
requires = ["setuptools>=41.2", "cython>=0.29.20", "wheel", "oldest-supported-numpy"]
33
build-backend = "setuptools.build_meta"

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
check-manifest
22
coverage
33
coveralls
4-
cython>0.26.1
4+
cython>=0.29.20
55
pytest
66
pytest-cov
77
sphinx

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616
BASEDIR = os.path.abspath(os.path.dirname(__file__))
1717
SRCDIR = os.path.join(BASEDIR,'src')
1818
CMDS_NOCYTHONIZE = ['clean','clean_cython','sdist']
19-
COMPILER_DIRECTIVES = {}
19+
COMPILER_DIRECTIVES = {
20+
# Cython 3.0.0 changes the default of the c_api_binop_methods directive to
21+
# False, resulting in errors in datetime and timedelta arithmetic:
22+
# https://github.com/Unidata/cftime/issues/271. We explicitly set it to
23+
# True to retain Cython 0.x behavior for future Cython versions. This
24+
# directive was added in Cython version 0.29.20.
25+
"c_api_binop_methods": True
26+
}
2027
DEFINE_MACROS = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
2128
FLAG_COVERAGE = '--cython-coverage' # custom flag enabling Cython line tracing
2229
NAME = 'cftime'

0 commit comments

Comments
 (0)