aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/extension.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2012-03-10 22:17:12 -0800
committerJason R. Coombs <jaraco@jaraco.com>2012-03-10 22:17:12 -0800
commit9f5991b303d87d49479381b971652950f0cfdac1 (patch)
treeb5feb853bb66c81156031480980f09bf783f845e /setuptools/extension.py
parent5e47a200c412793a2878e3df57f29e854e2e9356 (diff)
downloadexternal_python_setuptools-9f5991b303d87d49479381b971652950f0cfdac1.tar.gz
external_python_setuptools-9f5991b303d87d49479381b971652950f0cfdac1.tar.bz2
external_python_setuptools-9f5991b303d87d49479381b971652950f0cfdac1.zip
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
Diffstat (limited to 'setuptools/extension.py')
-rw-r--r--setuptools/extension.py20
1 files changed, 9 insertions, 11 deletions
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"""