##// END OF EJS Templates
setup: ignore failures to build optional inotify extension
Christian Boos -
r11468:1c1126b1 stable
parent child Browse files
Show More
@@ -35,12 +35,15 b' except:'
35 35 import os, subprocess, time
36 36 import shutil
37 37 import tempfile
38 from distutils import log
38 39 from distutils.core import setup, Extension
39 40 from distutils.dist import Distribution
40 41 from distutils.command.build import build
42 from distutils.command.build_ext import build_ext
41 43 from distutils.command.build_py import build_py
42 44 from distutils.spawn import spawn, find_executable
43 45 from distutils.ccompiler import new_compiler
46 from distutils.errors import CCompilerError
44 47
45 48 scripts = ['hg']
46 49 if os.name == 'nt':
@@ -209,6 +212,17 b' Distribution.pure = 0'
209 212 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
210 213 "code instead of C extensions"))
211 214
215 class hgbuildext(build_ext):
216
217 def build_extension(self, ext):
218 try:
219 build_ext.build_extension(self, ext)
220 except CCompilerError:
221 if not hasattr(ext, 'optional') or not ext.optional:
222 raise
223 log.warn("Failed to build optional extension '%s' (skipping)",
224 ext.name)
225
212 226 class hgbuildpy(build_py):
213 227
214 228 def finalize_options(self):
@@ -232,6 +246,7 b' class hgbuildpy(build_py):'
232 246 yield module
233 247
234 248 cmdclass = {'build_mo': hgbuildmo,
249 'build_ext': hgbuildext,
235 250 'build_py': hgbuildpy}
236 251
237 252 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
@@ -256,10 +271,13 b' else:'
256 271 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
257 272 # The inotify extension is only usable with Linux 2.6 kernels.
258 273 # You also need a reasonably recent C library.
274 # In any case, if it fails to build the error will be skipped ('optional').
259 275 cc = new_compiler()
260 276 if hasfunction(cc, 'inotify_add_watch'):
261 extmodules.append(Extension('hgext.inotify.linux._inotify',
262 ['hgext/inotify/linux/_inotify.c']))
277 inotify = Extension('hgext.inotify.linux._inotify',
278 ['hgext/inotify/linux/_inotify.c'])
279 inotify.optional = True
280 extmodules.append(inotify)
263 281 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
264 282
265 283 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
General Comments 0
You need to be logged in to leave comments. Login now