Ticket #3586: patch2.txt

File patch2.txt, 1.9 KB (added by soult, 5 years ago)
Line 
1diff --git a/twisted/python/dist.py b/twisted/python/dist.py
2index 5727065..380c0ab 100644
3--- a/twisted/python/dist.py
4+++ b/twisted/python/dist.py
5@@ -8,7 +8,7 @@ Maintainer: Christopher Armstrong
6 
7 import sys, os
8 from distutils.command import build_scripts, install_data, build_ext, build_py
9-from distutils.errors import CompileError
10+from distutils.errors import CompileError, CCompilerError, DistutilsPlatformError
11 from distutils import core
12 from distutils.core import Extension
13 
14@@ -296,6 +296,13 @@ class install_data_twisted(install_data.install_data):
15 
16 
17 
18+# The technique of ignoring CCompilerError is copied from simplejson 2.1.1.
19+BUILD_EXT_WARNING="""
20+WARNING: The C extension could not be compiled, speedups are not enabled.
21+
22+Above is the output showing how the compilation failed.
23+"""
24+
25 class build_ext_twisted(build_ext.build_ext):
26     """
27     Allow subclasses to easily detect and customize Extensions to
28@@ -325,8 +332,16 @@ class build_ext_twisted(build_ext.build_ext):
29         Check to see which extension modules to build and then build them.
30         """
31         self.prepare_extensions()
32-        build_ext.build_ext.build_extensions(self)
33-
34+        try:
35+            build_ext.build_ext.build_extensions(self)
36+        except CCompilerError, x:
37+            print ('*'*70+'\n')
38+            print BUILD_EXT_WARNING
39+            print ('*'*70+'\n')
40+        except DistutilsPlatformError, x:
41+            print ('*'*70+'\n')
42+            print BUILD_EXT_WARNING
43+            print ('*'*70+'\n')
44 
45     def _remove_conftest(self):
46         for filename in ("conftest.c", "conftest.o", "conftest.obj"):
47@@ -346,6 +361,8 @@ class build_ext_twisted(build_ext.build_ext):
48                 self.compiler.compile(["conftest.c"], output_dir='')
49             except CompileError:
50                 return False
51+            except DistutilsPlatformError:
52+                return False
53             return True
54         finally:
55             self._remove_conftest()