blob: cfcf55bf1a4ba91b915bcae74d88ccbbd99d3e8e [file] [log] [blame]
Phillip J. Eby069159b2006-04-18 04:05:34 +00001from distutils.core import Extension as _Extension
2from dist import _get_unpatched
3_Extension = _get_unpatched(_Extension)
4
5try:
6 from Pyrex.Distutils.build_ext import build_ext
7except ImportError:
8 have_pyrex = False
9else:
10 have_pyrex = True
11
12
13class Extension(_Extension):
14 """Extension that uses '.c' files in place of '.pyx' files"""
15
16 if not have_pyrex:
Tim Peters584b0e02006-04-18 17:32:12 +000017 # convert .pyx extensions to .c
Phillip J. Eby069159b2006-04-18 04:05:34 +000018 def __init__(self,*args,**kw):
19 _Extension.__init__(self,*args,**kw)
20 sources = []
21 for s in self.sources:
22 if s.endswith('.pyx'):
23 sources.append(s[:-3]+'c')
24 else:
25 sources.append(s)
26 self.sources = sources
27
28class Library(Extension):
29 """Just like a regular Extension, but built as a library instead"""
30
31import sys, distutils.core, distutils.extension
32distutils.core.Extension = Extension
33distutils.extension.Extension = Extension
34if 'distutils.command.build_ext' in sys.modules:
35 sys.modules['distutils.command.build_ext'].Extension = Extension