File: extension.py

package info (click to toggle)
python-setuptools 0.0.1.041214-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 232 kB
  • ctags: 264
  • sloc: python: 931; makefile: 37
file content (27 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from distutils.core import Extension as _Extension

try:
    from Pyrex.Distutils.build_ext import build_ext

except ImportError:

    # Pyrex isn't around, so fix up the sources

    class Extension(_Extension):

        """Extension that uses '.c' files in place of '.pyx' files"""

        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

else:

    # Pyrex is here, just use regular extension type
    Extension = _Extension