
import distutils.command.build_ext

class build_ext (distutils.command.build_ext.build_ext):
    def run(self):
        if type(self) is build_ext and self.extensions:
            for extension in self.extensions:
                sources = []
                for s in extension.sources:
                    if s.endswith('.pyx'):
                        sources.append(s[:-3]+'c')
                    else:
                        sources.append(s)
                extension.sources = sources
        super(build_ext, self).run()

import sys
distutils.command.build_ext = build_ext
if 'distutils.command.build_ext' in sys.modules:
    sys.modules['distutils.command.build_ext'] = build_ext
