Rev 87: Merge the setup.py changes so that it actually fails if an extension fails to build. in http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/rabin

John Arbash Meinel john at arbash-meinel.com
Tue Mar 3 15:04:50 GMT 2009


At http://bazaar.launchpad.net/%7Ebzr/bzr-groupcompress/rabin

------------------------------------------------------------
revno: 87
revision-id: john at arbash-meinel.com-20090303150400-3il0kyvau1ho5vww
parent: john at arbash-meinel.com-20090303145931-5ahrrw6hycii49xj
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: rabin
timestamp: Tue 2009-03-03 09:04:00 -0600
message:
  Merge the setup.py changes so that it actually fails if an extension fails to build.
-------------- next part --------------
=== modified file 'setup.py'
--- a/setup.py	2009-03-02 17:05:33 +0000
+++ b/setup.py	2009-03-03 15:04:00 +0000
@@ -28,20 +28,42 @@
 
 class build_ext_if_possible(build_ext):
 
+    user_options = build_ext.user_options + [
+        ('allow-python-fallback', None,
+         "When an extension cannot be built, allow falling"
+         " back to the pure-python implementation.")
+        ]
+
+    def initialize_options(self):
+        build_ext.initialize_options(self)
+        self.allow_python_fallback = False
+
     def run(self):
         try:
             build_ext.run(self)
         except DistutilsPlatformError, e:
+            if not self.allow_python_fallback:
+                log.warn('\n  Cannot build extensions.\n'
+                         '  Use "build_ext --allow-python-fallback" to use'
+                         ' slower python implementations instead.\n')
+                raise
             log.warn(str(e))
-            log.warn('Extensions cannot be built, '
-                     'will use the Python versions instead')
+            log.warn('\n  Extensions cannot be built.\n'
+                     '  Using the slower Python implementations instead.\n')
 
     def build_extension(self, ext):
         try:
             build_ext.build_extension(self, ext)
         except CCompilerError:
-            log.warn('Building of "%s" extension failed, '
-                     'will use the Python version instead' % (ext.name,))
+            if not self.allow_python_fallback:
+                log.warn('\n  Cannot build extension (%s).\n'
+                         '  Use "build_ext --allow-python-fallback" to use'
+                         ' slower python implementations instead.\n'
+                         % (ext.name,))
+                raise
+            log.warn('\n  Building of "%s" extension failed.\n'
+                     '  Using the slower Python implementation instead.'
+                     % (ext.name,))
 
 
 # Override the build_ext if we have Pyrex available



More information about the bazaar-commits mailing list