aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/setup.py
diff options
context:
space:
mode:
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py48
1 files changed, 33 insertions, 15 deletions
diff --git a/setup.py b/setup.py
index 277965837c3..0f88e78c616 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:
@@ -173,6 +178,9 @@ class PyBuildExt(build_ext):
def __init__(self, dist):
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):
@@ -252,9 +260,13 @@ 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], default=0)
- if self.failed:
- longest = max(longest, max([len(name) for name in self.failed]))
+ if self.failed or self.failed_on_import:
+ all_failed = self.failed + self.failed_on_import
+ longest = max(longest, max([len(name) for name in all_failed]))
def print_three_column(lst):
lst.sort(key=str.lower)
@@ -282,6 +294,14 @@ class PyBuildExt(build_ext):
print_three_column(failed)
print()
+ if self.failed_on_import:
+ failed = self.failed_on_import[:]
+ print()
+ print("Following modules built successfully"
+ " but were removed because they could not be imported:")
+ print_three_column(failed)
+ print()
+
def build_extension(self, ext):
if ext.name == '_ctypes':
@@ -295,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:
@@ -338,9 +367,9 @@ class PyBuildExt(build_ext):
spec = importlib.util.spec_from_file_location(ext.name, ext_filename,
loader=loader)
try:
- importlib._bootstrap._SpecMethods(spec).load()
+ importlib._bootstrap._load(spec)
except ImportError as why:
- self.failed.append(ext.name)
+ self.failed_on_import.append(ext.name)
self.announce('*** WARNING: renaming "%s" since importing it'
' failed: %s' % (ext.name, why), level=3)
assert not self.inplace
@@ -350,17 +379,6 @@ class PyBuildExt(build_ext):
os.remove(newname)
os.rename(ext_filename, newname)
- # XXX -- This relies on a Vile HACK in
- # distutils.command.build_ext.build_extension(). The
- # _built_objects attribute is stored there strictly for
- # use here.
- # If there is a failure, _built_objects may not be there,
- # so catch the AttributeError and move on.
- try:
- for filename in self._built_objects:
- os.remove(filename)
- except AttributeError:
- self.announce('unable to remove files (ignored)')
except:
exc_type, why, tb = sys.exc_info()
self.announce('*** WARNING: importing extension "%s" '