From 9f5991b303d87d49479381b971652950f0cfdac1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 10 Mar 2012 22:17:12 -0800 Subject: Refactored Extension class so that __init__ is always called, but patched behavior is still selected by has_pyrex. --HG-- branch : distribute extra : rebase_source : d5670bf4bc6606d828b4ec7be055e26a7d4a9730 --- setuptools/extension.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'setuptools/extension.py') diff --git a/setuptools/extension.py b/setuptools/extension.py index e87494ad..db563305 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -21,17 +21,15 @@ have_pyrex = 'build_ext' in globals() class Extension(_Extension): """Extension that uses '.c' files in place of '.pyx' files""" - if not have_pyrex: - # convert .pyx extensions to .c - def __init__(self, *args, **kw): - _Extension.__init__(self, *args, **kw) - sources = [] - for s in self.sources: - if s.endswith('.pyx'): - sources.append(s[:-3] + 'c') - else: - sources.append(s) - self.sources = sources + def __init__(self, *args, **kw): + _Extension.__init__(self, *args, **kw) + if not have_pyrex: + self._convert_pyx_sources_to_c() + + def _convert_pyx_sources_to_c(self): + "convert .pyx extensions to .c" + self.sources = [source[:-3] + 'c' for source in self.sources + if source.endswith('.pyx')] class Library(Extension): """Just like a regular Extension, but built as a library instead""" -- cgit v1.2.3