changeset 6245:0d0939b2d272

setup.py: skip inotify if there's no inotify_add_watch Debian Etch doesn't include a sys/inotify.h header, which makes it impossible to compile _inotify.c, making hg uninstallable. The cc.has_function() method is implemented by trying to compile a simple C program. Since there's no redirection involved all error messages are sent to the terminal. This is not particularly pretty but at least it allows the installation to complete.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Thu, 13 Mar 2008 19:50:03 -0300
parents b36774d0fce1
children 35bf9c23e17a
files setup.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Thu Mar 13 17:39:30 2008 +0100
+++ b/setup.py	Thu Mar 13 19:50:03 2008 -0300
@@ -12,6 +12,7 @@
 import os
 from distutils.core import setup, Extension
 from distutils.command.install_data import install_data
+from distutils.ccompiler import new_compiler
 
 import mercurial.version
 
@@ -66,10 +67,13 @@
     ext_modules.append(Extension('mercurial.osutil', ['mercurial/osutil.c']))
 
     if sys.platform == 'linux2' and os.uname()[2] > '2.6':
-        # the inotify extension is only usable with Linux 2.6 kernels
-        ext_modules.append(Extension('hgext.inotify.linux._inotify',
-                                     ['hgext/inotify/linux/_inotify.c']))
-        packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
+        # The inotify extension is only usable with Linux 2.6 kernels.
+        # You also need a reasonably recent C library.
+        cc = new_compiler()
+        if cc.has_function('inotify_add_watch'):
+            ext_modules.append(Extension('hgext.inotify.linux._inotify',
+                                         ['hgext/inotify/linux/_inotify.c']))
+            packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
 except ImportError:
     pass