diff --git a/twisted/python/dist.py b/twisted/python/dist.py index 5727065..380c0ab 100644 --- a/twisted/python/dist.py +++ b/twisted/python/dist.py @@ -8,7 +8,7 @@ Maintainer: Christopher Armstrong import sys, os from distutils.command import build_scripts, install_data, build_ext, build_py -from distutils.errors import CompileError +from distutils.errors import CompileError, CCompilerError, DistutilsPlatformError from distutils import core from distutils.core import Extension @@ -296,6 +296,13 @@ class install_data_twisted(install_data.install_data): +# The technique of ignoring CCompilerError is copied from simplejson 2.1.1. +BUILD_EXT_WARNING=""" +WARNING: The C extension could not be compiled, speedups are not enabled. + +Above is the output showing how the compilation failed. +""" + class build_ext_twisted(build_ext.build_ext): """ Allow subclasses to easily detect and customize Extensions to @@ -325,8 +332,16 @@ class build_ext_twisted(build_ext.build_ext): Check to see which extension modules to build and then build them. """ self.prepare_extensions() - build_ext.build_ext.build_extensions(self) - + try: + build_ext.build_ext.build_extensions(self) + except CCompilerError, x: + print ('*'*70+'\n') + print BUILD_EXT_WARNING + print ('*'*70+'\n') + except DistutilsPlatformError, x: + print ('*'*70+'\n') + print BUILD_EXT_WARNING + print ('*'*70+'\n') def _remove_conftest(self): for filename in ("conftest.c", "conftest.o", "conftest.obj"): @@ -346,6 +361,8 @@ class build_ext_twisted(build_ext.build_ext): self.compiler.compile(["conftest.c"], output_dir='') except CompileError: return False + except DistutilsPlatformError: + return False return True finally: self._remove_conftest()