From 088053e3f66251c054a507f52f5f9e28d540dbe9 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Tue, 7 Jan 2020 10:06:51 +0100 Subject: [PATCH] BLD: more informative error message when trying to cythonize with old cython version --- setup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 076b77bf5d4df..c33ce063cb4d9 100755 --- a/setup.py +++ b/setup.py @@ -49,11 +49,12 @@ def is_platform_mac(): try: import Cython - ver = Cython.__version__ + _CYTHON_VERSION = Cython.__version__ from Cython.Build import cythonize - _CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver) + _CYTHON_INSTALLED = _CYTHON_VERSION >= LooseVersion(min_cython_ver) except ImportError: + _CYTHON_VERSION = None _CYTHON_INSTALLED = False cythonize = lambda x, *args, **kwargs: x # dummy func @@ -506,6 +507,11 @@ def maybe_cythonize(extensions, *args, **kwargs): elif not cython: # GH#28836 raise a helfpul error message + if _CYTHON_VERSION: + raise RuntimeError( + f"Cannot cythonize with old Cython version ({_CYTHON_VERSION} " + f"installed, needs {min_cython_ver})" + ) raise RuntimeError("Cannot cythonize without Cython installed.") numpy_incl = pkg_resources.resource_filename("numpy", "core/include")