build_ext.py 1007 B

12345678910111213141516171819202122232425
  1. import sys
  2. if 'setuptools' in sys.modules:
  3. try:
  4. from setuptools.command.build_ext import build_ext as _build_ext
  5. except ImportError:
  6. # We may be in the process of importing setuptools, which tries
  7. # to import this.
  8. from distutils.command.build_ext import build_ext as _build_ext
  9. else:
  10. from distutils.command.build_ext import build_ext as _build_ext
  11. class new_build_ext(_build_ext, object):
  12. def finalize_options(self):
  13. if self.distribution.ext_modules:
  14. nthreads = getattr(self, 'parallel', None) # -j option in Py3.5+
  15. nthreads = int(nthreads) if nthreads else None
  16. from Cython.Build.Dependencies import cythonize
  17. self.distribution.ext_modules[:] = cythonize(
  18. self.distribution.ext_modules, nthreads=nthreads, force=self.force)
  19. super(new_build_ext, self).finalize_options()
  20. # This will become new_build_ext in the future.
  21. from .old_build_ext import old_build_ext as build_ext