At http://bzr.arbash-meinel.com/branches/bzr/1.8-dev/setup_fail

------------------------------------------------------------
revno: 3760
revision-id: [EMAIL PROTECTED]
parent: [EMAIL PROTECTED]
committer: John Arbash Meinel <[EMAIL PROTECTED]>
branch nick: setup_fail
timestamp: Thu 2008-10-02 11:35:05 -0500
message:
  Default to requiring extensions.
  
  The build process will fail if extensions cannot be compiled, unless
  --allow-python-fallback is supplied.
  This helps PQM to make sure extensions are tested, and helps
  users by having them explicitly allow non-compiled forms.
=== modified file 'setup.py'
--- a/setup.py  2008-09-26 05:14:51 +0000
+++ b/setup.py  2008-10-02 16:35:05 +0000
@@ -144,6 +144,7 @@
     """Customized build distutils action.
     Generate bzr.1.
     """
+
     def run(self):
         build.run(self)
 
@@ -179,20 +180,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 --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  Failed to build "%s".\n'
+                         '  Use --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

-- 
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits

Reply via email to