From a811c089a4362c0dc6c4a84b708953dde9ebdbf8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 10 Jun 2015 12:33:54 -0400 Subject: Detect Cython later in the build process, allowing the library to be specified in setup_requires. Fixes #288. --- setuptools/extension.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'setuptools/extension.py') diff --git a/setuptools/extension.py b/setuptools/extension.py index 8178ed33..a7c40f86 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -12,35 +12,34 @@ _Extension = _get_unpatched(distutils.core.Extension) msvc9_support.patch_for_specialized_compiler() -def have_pyrex(): +def _have_cython(): """ - Return True if Cython or Pyrex can be imported. + Return True if Cython can be imported. """ - pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext' - for pyrex_impl in pyrex_impls: + cython_impls = 'Cython.Distutils.build_ext', + for cython_impl in cython_impls: try: - # from (pyrex_impl) import build_ext - __import__(pyrex_impl, fromlist=['build_ext']).build_ext + # from (cython_impl) import build_ext + __import__(cython_impl, fromlist=['build_ext']).build_ext return True except Exception: pass return False +# for compatibility +have_pyrex = _have_cython + class Extension(_Extension): """Extension that uses '.c' files in place of '.pyx' files""" - def __init__(self, *args, **kw): - _Extension.__init__(self, *args, **kw) - self._convert_pyx_sources_to_lang() - def _convert_pyx_sources_to_lang(self): """ Replace sources with .pyx extensions to sources with the target language extension. This mechanism allows language authors to supply pre-converted sources but to prefer the .pyx sources. """ - if have_pyrex(): + if _have_cython(): # the build has Cython, so allow it to compile the .pyx files return lang = self.language or '' -- cgit v1.2.1 From 3c047624cfa74a42320334ed6ec0dd7b6bd789b6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 10 Jun 2015 14:56:52 -0400 Subject: Remove loop, made unnecessary by removal of support for Pyrex --- setuptools/extension.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'setuptools/extension.py') diff --git a/setuptools/extension.py b/setuptools/extension.py index a7c40f86..35eb7c7c 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -16,14 +16,13 @@ def _have_cython(): """ Return True if Cython can be imported. """ - cython_impls = 'Cython.Distutils.build_ext', - for cython_impl in cython_impls: - try: - # from (cython_impl) import build_ext - __import__(cython_impl, fromlist=['build_ext']).build_ext - return True - except Exception: - pass + cython_impl = 'Cython.Distutils.build_ext', + try: + # from (cython_impl) import build_ext + __import__(cython_impl, fromlist=['build_ext']).build_ext + return True + except Exception: + pass return False # for compatibility -- cgit v1.2.1