Rev 2866: `setup.py install` on systems without C-compiler in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Sep 25 22:28:05 BST 2007


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

------------------------------------------------------------
revno: 2866
revision-id: pqm at pqm.ubuntu.com-20070925212801-8p7l0qlplb0t7h2u
parent: pqm at pqm.ubuntu.com-20070925205148-yd27v1odc65uql59
parent: bialix at ukr.net-20070925194100-zw5hcmc85hf3m0uf
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-09-25 22:28:01 +0100
message:
  `setup.py install` on systems without C-compiler
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  setup.py                       setup.py-20050314065409-02f8a0a6e3f9bc70
    ------------------------------------------------------------
    revno: 2814.4.6
    merged: bialix at ukr.net-20070925194100-zw5hcmc85hf3m0uf
    parent: bialix at ukr.net-20070915051300-fyhdnjmmv97uec4u
    parent: pqm at pqm.ubuntu.com-20070925092014-7t2piu8gmm5hvbks
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: install.wo.compiler
    timestamp: Tue 2007-09-25 22:41:00 +0300
    message:
      merge bzr.dev
    ------------------------------------------------------------
    revno: 2814.4.5
    merged: bialix at ukr.net-20070915051300-fyhdnjmmv97uec4u
    parent: bialix at ukr.net-20070914113928-u2my9p5l1oxdq760
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: install.wo.compiler
    timestamp: Sat 2007-09-15 08:13:00 +0300
    message:
      double quotes for extension name
    ------------------------------------------------------------
    revno: 2814.4.4
    merged: bialix at ukr.net-20070914113928-u2my9p5l1oxdq760
    parent: bialix at ukr.net-20070913122547-019sbxz14kyyl37l
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: install.wo.compiler
    timestamp: Fri 2007-09-14 14:39:28 +0300
    message:
      changes suggested by Aaron and Martin
    ------------------------------------------------------------
    revno: 2814.4.3
    merged: bialix at ukr.net-20070913122547-019sbxz14kyyl37l
    parent: bialix at ukr.net-20070913110018-whu5m8wfdu7j3n5e
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: install.wo.compiler
    timestamp: Thu 2007-09-13 15:25:47 +0300
    message:
      fixed incomplete try-except
    ------------------------------------------------------------
    revno: 2814.4.2
    merged: bialix at ukr.net-20070913110018-whu5m8wfdu7j3n5e
    parent: lalinsky at gmail.com-20070911080621-kru223e15w1fkzaa
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: install.wo.compiler
    timestamp: Thu 2007-09-13 14:00:18 +0300
    message:
      support for win32
    ------------------------------------------------------------
    revno: 2814.4.1
    merged: lalinsky at gmail.com-20070911080621-kru223e15w1fkzaa
    parent: pqm at pqm.ubuntu.com-20070911055622-a3060rj7l0iy38l2
    committer: Lukáš Lalinský <lalinsky at gmail.com>
    branch nick: build_ext_if_possible
    timestamp: Tue 2007-09-11 10:06:21 +0200
    message:
      Don't abort ``python setup.py install`` if building of a C extension is not possible.
=== modified file 'NEWS'
--- a/NEWS	2007-09-25 20:19:21 +0000
+++ b/NEWS	2007-09-25 21:28:01 +0000
@@ -295,6 +295,10 @@
       changed or deleted, and are copied into the checkout when it is 
       updated.  (Martin Pool, #93856, #93860)
 
+   * Print a warning instead of aborting the ``python setup.py install``
+     process if building of a C extension is not possible.
+     (Lukáš Lalinský, Alexander Belchenko)
+
   IMPROVEMENTS:
 
    * Add the option "--show-diff" to the commit command in order to display

=== modified file 'setup.py'
--- a/setup.py	2007-09-04 09:10:35 +0000
+++ b/setup.py	2007-09-15 05:13:00 +0000
@@ -149,6 +149,8 @@
 
 command_classes = {'install_scripts': my_install_scripts,
                    'build': bzr_build}
+from distutils import log
+from distutils.errors import CCompilerError, DistutilsPlatformError
 from distutils.extension import Extension
 ext_modules = []
 try:
@@ -165,8 +167,28 @@
     from distutils.command.build_ext import build_ext
 else:
     have_pyrex = True
+
+
+class build_ext_if_possible(build_ext):
+
+    def run(self):
+        try:
+            build_ext.run(self)
+        except DistutilsPlatformError, e:
+            log.warn(str(e))
+            log.warn('Extensions cannot be built, '
+                     'will use the Python versions instead')
+
+    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,))
+
+
 # Override the build_ext if we have Pyrex available
-command_classes['build_ext'] = build_ext
+command_classes['build_ext'] = build_ext_if_possible
 unavailable_files = []
 
 
@@ -230,7 +252,7 @@
             # help pages
             'data_files': find_docs(),
             # for building pyrex extensions
-            'cmdclass': {'build_ext': build_ext},
+            'cmdclass': {'build_ext': build_ext_if_possible},
            }
 
     ARGS.update(META_INFO)




More information about the bazaar-commits mailing list