Mercurial > hg-stable
changeset 11468:1c1126b1d919 stable
setup: ignore failures to build optional inotify extension
author | Christian Boos <cboos@neuf.fr> |
---|---|
date | Wed, 23 Jun 2010 13:44:07 +0200 |
parents | 6b836d5c8c9e |
children | c37f35d7f2f5 |
files | setup.py |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Wed Jun 30 17:44:36 2010 -0500 +++ b/setup.py Wed Jun 23 13:44:07 2010 +0200 @@ -35,12 +35,15 @@ import os, subprocess, time import shutil import tempfile +from distutils import log from distutils.core import setup, Extension from distutils.dist import Distribution from distutils.command.build import build +from distutils.command.build_ext import build_ext from distutils.command.build_py import build_py from distutils.spawn import spawn, find_executable from distutils.ccompiler import new_compiler +from distutils.errors import CCompilerError scripts = ['hg'] if os.name == 'nt': @@ -209,6 +212,17 @@ Distribution.global_options.append(('pure', None, "use pure (slow) Python " "code instead of C extensions")) +class hgbuildext(build_ext): + + def build_extension(self, ext): + try: + build_ext.build_extension(self, ext) + except CCompilerError: + if not hasattr(ext, 'optional') or not ext.optional: + raise + log.warn("Failed to build optional extension '%s' (skipping)", + ext.name) + class hgbuildpy(build_py): def finalize_options(self): @@ -232,6 +246,7 @@ yield module cmdclass = {'build_mo': hgbuildmo, + 'build_ext': hgbuildext, 'build_py': hgbuildpy} packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert', @@ -256,10 +271,13 @@ if sys.platform == 'linux2' and os.uname()[2] > '2.6': # The inotify extension is only usable with Linux 2.6 kernels. # You also need a reasonably recent C library. + # In any case, if it fails to build the error will be skipped ('optional'). cc = new_compiler() if hasfunction(cc, 'inotify_add_watch'): - extmodules.append(Extension('hgext.inotify.linux._inotify', - ['hgext/inotify/linux/_inotify.c'])) + inotify = Extension('hgext.inotify.linux._inotify', + ['hgext/inotify/linux/_inotify.c']) + inotify.optional = True + extmodules.append(inotify) packages.extend(['hgext.inotify', 'hgext.inotify.linux']) packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',