Rev 3772: (jam) Change the setup.py build process to fail unless in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Oct 10 20:41:47 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3772
revision-id: pqm at pqm.ubuntu.com-20081010194144-0hujuzlipigm8pbs
parent: pqm at pqm.ubuntu.com-20081009222709-e64jq9sfyzvqjbn2
parent: john at arbash-meinel.com-20081002163505-sscy52tfqzz7ltg9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2008-10-10 20:41:44 +0100
message:
  (jam) Change the setup.py build process to fail unless
  	--allow-python-fallback is supplied.
modified:
  setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
    ------------------------------------------------------------
    revno: 3759.1.1
    revision-id: john at arbash-meinel.com-20081002163505-sscy52tfqzz7ltg9
    parent: pqm at pqm.ubuntu.com-20081002065404-0sjc6vwukw26m5wo
    committer: John Arbash Meinel <john at arbash-meinel.com>
    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:
      setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
=== modified file 'setup.py'
--- a/setup.py	2008-10-02 15:36:12 +0000
+++ b/setup.py	2008-10-10 19:41:44 +0000
@@ -144,6 +144,7 @@
     """Customized build distutils action.
     Generate bzr.1.
     """
+
     def run(self):
         build.run(self)
 
@@ -180,20 +181,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




More information about the bazaar-commits mailing list