Skip to content

Commit b5da1ae

Browse files
jorisvandenbosscheTomAugspurger
authored andcommitted
BLD: more informative error message when trying to cythonize with old cython version (#30774)
1 parent 090957c commit b5da1ae

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

setup.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ def is_platform_mac():
4949
try:
5050
import Cython
5151

52-
ver = Cython.__version__
52+
_CYTHON_VERSION = Cython.__version__
5353
from Cython.Build import cythonize
5454

55-
_CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver)
55+
_CYTHON_INSTALLED = _CYTHON_VERSION >= LooseVersion(min_cython_ver)
5656
except ImportError:
57+
_CYTHON_VERSION = None
5758
_CYTHON_INSTALLED = False
5859
cythonize = lambda x, *args, **kwargs: x # dummy func
5960

@@ -506,6 +507,11 @@ def maybe_cythonize(extensions, *args, **kwargs):
506507

507508
elif not cython:
508509
# GH#28836 raise a helfpul error message
510+
if _CYTHON_VERSION:
511+
raise RuntimeError(
512+
f"Cannot cythonize with old Cython version ({_CYTHON_VERSION} "
513+
f"installed, needs {min_cython_ver})"
514+
)
509515
raise RuntimeError("Cannot cythonize without Cython installed.")
510516

511517
numpy_incl = pkg_resources.resource_filename("numpy", "core/include")

0 commit comments

Comments
 (0)