aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Distutils/build_ext.py
blob: c499bb525adf95405a372c886625347b46bef557 (plain) (blame)
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
import sys

if 'setuptools' in sys.modules: 
    try: 
        from setuptools.command.build_ext import build_ext as _build_ext 
    except ImportError: 
        # We may be in the process of importing setuptools, which tries 
        # to import this. 
        from distutils.command.build_ext import build_ext as _build_ext 
else: 
    from distutils.command.build_ext import build_ext as _build_ext 
 

class new_build_ext(_build_ext, object): 
    def finalize_options(self): 
        if self.distribution.ext_modules: 
            nthreads = getattr(self, 'parallel', None)  # -j option in Py3.5+
            nthreads = int(nthreads) if nthreads else None
            from Cython.Build.Dependencies import cythonize 
            self.distribution.ext_modules[:] = cythonize( 
                self.distribution.ext_modules, nthreads=nthreads, force=self.force)
        super(new_build_ext, self).finalize_options()

# This will become new_build_ext in the future. 
from .old_build_ext import old_build_ext as build_ext