always run cythonize
@@ -19,6 +19,8 @@ from install.build import PLATFORM_LINUX
from install.build import PLATFORM_WIN32
+# Cython requirements (minimum version and versions known to be broken).
+# Note: this must be in sync with setup_requires defined in setup.py.
required_cython_version = pkg_resources.parse_version('0.28.0')
ignore_cython_versions = [
]
@@ -365,14 +367,7 @@ def module_extension_name(file):
def module_extension_sources(file, use_cython, no_cuda):
pyx, others = ensure_module_file(file)
base = path.join(*pyx.split('.'))
- if use_cython:
- pyx = base + '.pyx'
- if not os.path.exists(pyx):
- use_cython = False
- print(
- 'NOTICE: Skipping cythonize as {} does not exist.'.format(pyx))
- if not use_cython:
- pyx = base + '.cpp'
+ pyx = base + ('.pyx' if use_cython else '.cpp')
# If CUDA SDK is not available, remove CUDA C files from extension sources
# and use stubs defined in header files.
@@ -804,18 +799,16 @@ def prepare_wheel_libs():
return [os.path.relpath(x[1], 'cupy') for x in files_to_copy]
-try:
+def cythonize(extensions, arg_options):
+ # Delay importing Cython as it may be installed via setup_requires if
+ # the user does not have Cython installed.
import Cython
import Cython.Build
cython_version = pkg_resources.parse_version(Cython.__version__)
- cython_available = (
- cython_version >= required_cython_version and
- cython_version not in ignore_cython_versions)
-except ImportError:
- cython_available = False
+ if (cython_version < required_cython_version or
+ cython_version in ignore_cython_versions):
+ raise AssertionError('Unsupported Cython version')
-
-def cythonize(extensions, arg_options):
directive_keys = ('linetrace', 'profile')
directives = {key: arg_options[key] for key in directive_keys}
@@ -1116,7 +1109,6 @@ class custom_build_ext(build_ext.build_ext):
# Intentionally causes DistutilsPlatformError in
# ccompiler.new_compiler() function to hook.
self.compiler = 'nvidia'
- if cython_available:
ext_modules = get_ext_modules(True) # get .pyx modules
cythonize(ext_modules, cupy_setup_options)
check_extensions(self.extensions)
