summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-09-26 21:31:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-09-26 21:31:59 (GMT)
commit2c0a91606105e1606d886c198ea7ed1b195c692f (patch)
treefe0a91c1f633ab3dc48fad0c63f8960695b21ac3 /setup.py
parent7e23d82cec31c1035fb7d7808443a80e129dd112 (diff)
downloadcpython-2c0a91606105e1606d886c198ea7ed1b195c692f.zip
cpython-2c0a91606105e1606d886c198ea7ed1b195c692f.tar.gz
cpython-2c0a91606105e1606d886c198ea7ed1b195c692f.tar.bz2
Issue #5309: distutils' build and build_ext commands now accept a ``-j``
option to enable parallel building of extension modules.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 4691793..016c455 100644
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,11 @@ cflags = sysconfig.get_config_var('CFLAGS')
py_cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST')
sysconfig.get_config_vars()['CFLAGS'] = cflags + ' ' + py_cflags_nodist
+class Dummy:
+ """Hack for parallel build"""
+ ProcessPoolExecutor = None
+sys.modules['concurrent.futures.process'] = Dummy
+
def get_platform():
# cross build
if "_PYTHON_HOST_PLATFORM" in os.environ:
@@ -174,6 +179,8 @@ class PyBuildExt(build_ext):
build_ext.__init__(self, dist)
self.failed = []
self.failed_on_import = []
+ if '-j' in os.environ.get('MAKEFLAGS', ''):
+ self.parallel = True
def build_extensions(self):
@@ -253,6 +260,9 @@ class PyBuildExt(build_ext):
build_ext.build_extensions(self)
+ for ext in self.extensions:
+ self.check_extension_import(ext)
+
longest = max([len(e.name) for e in self.extensions])
if self.failed or self.failed_on_import:
all_failed = self.failed + self.failed_on_import
@@ -305,6 +315,15 @@ class PyBuildExt(build_ext):
(ext.name, sys.exc_info()[1]))
self.failed.append(ext.name)
return
+
+ def check_extension_import(self, ext):
+ # Don't try to import an extension that has failed to compile
+ if ext.name in self.failed:
+ self.announce(
+ 'WARNING: skipping import check for failed build "%s"' %
+ ext.name, level=1)
+ return
+
# Workaround for Mac OS X: The Carbon-based modules cannot be
# reliably imported into a command-line Python
if 'Carbon' in ext.extra_link_args: