From c60c5df22eab4e1bd4eead560e18184ebdcca108 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 18 Mar 2011 10:44:42 -0400 Subject: Refactored Cython/Pyrex optional build support to unify logic --HG-- branch : distribute extra : rebase_source : c924cf1817736349e9a254098b6d99cd97a3d35f --- setuptools/extension.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'setuptools') 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): -- cgit v1.2.1