diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2011-03-18 10:44:42 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2011-03-18 10:44:42 -0400 |
commit | c60c5df22eab4e1bd4eead560e18184ebdcca108 (patch) | |
tree | 41a80eee3465050e81c5ea45d0b4003e15c0adac /setuptools/extension.py | |
parent | 0cb7fa265e11dcb58dcdf3a8be4497bf3beb01a3 (diff) | |
download | external_python_setuptools-c60c5df22eab4e1bd4eead560e18184ebdcca108.tar.gz external_python_setuptools-c60c5df22eab4e1bd4eead560e18184ebdcca108.tar.bz2 external_python_setuptools-c60c5df22eab4e1bd4eead560e18184ebdcca108.zip |
Refactored Cython/Pyrex optional build support to unify logic
--HG--
branch : distribute
extra : rebase_source : c924cf1817736349e9a254098b6d99cd97a3d35f
Diffstat (limited to 'setuptools/extension.py')
-rw-r--r-- | setuptools/extension.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/setuptools/extension.py b/setuptools/extension.py index df1ef02a..980ee0a7 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -2,20 +2,16 @@ from distutils.core import Extension as _Extension from setuptools.dist import _get_unpatched _Extension = _get_unpatched(_Extension) -try: - # testing Cython first as it is supposed to replace pyrex - from Cython.Distutils.build_ext import build_ext -except ImportError: - try: - from Pyrex.Distutils.build_ext import build_ext - except: - have_pyrex = False - else: - has_pyrex = True - - have_pyrex = False -else: - have_pyrex = True +# Prefer Cython to Pyrex +pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext' +for pyrex_impl in pyrex_impls: + try: + # from (pyrex_impl) import build_ext + build_ext = __import__(pyrex_impl, fromlist=['build_ext']).build_ext + break + except: + pass +have_pyrex = 'build_ext' in globals() class Extension(_Extension): |