##// 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 import os, subprocess, time
35 import os, subprocess, time
36 import shutil
36 import shutil
37 import tempfile
37 import tempfile
38 from distutils import log
38 from distutils.core import setup, Extension
39 from distutils.core import setup, Extension
39 from distutils.dist import Distribution
40 from distutils.dist import Distribution
40 from distutils.command.build import build
41 from distutils.command.build import build
42 from distutils.command.build_ext import build_ext
41 from distutils.command.build_py import build_py
43 from distutils.command.build_py import build_py
42 from distutils.spawn import spawn, find_executable
44 from distutils.spawn import spawn, find_executable
43 from distutils.ccompiler import new_compiler
45 from distutils.ccompiler import new_compiler
46 from distutils.errors import CCompilerError
44
47
45 scripts = ['hg']
48 scripts = ['hg']
46 if os.name == 'nt':
49 if os.name == 'nt':
@@ -209,6 +212,17 b' Distribution.pure = 0'
209 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
212 Distribution.global_options.append(('pure', None, "use pure (slow) Python "
210 "code instead of C extensions"))
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 class hgbuildpy(build_py):
226 class hgbuildpy(build_py):
213
227
214 def finalize_options(self):
228 def finalize_options(self):
@@ -232,6 +246,7 b' class hgbuildpy(build_py):'
232 yield module
246 yield module
233
247
234 cmdclass = {'build_mo': hgbuildmo,
248 cmdclass = {'build_mo': hgbuildmo,
249 'build_ext': hgbuildext,
235 'build_py': hgbuildpy}
250 'build_py': hgbuildpy}
236
251
237 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
252 packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
@@ -256,10 +271,13 b' else:'
256 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
271 if sys.platform == 'linux2' and os.uname()[2] > '2.6':
257 # The inotify extension is only usable with Linux 2.6 kernels.
272 # The inotify extension is only usable with Linux 2.6 kernels.
258 # You also need a reasonably recent C library.
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 cc = new_compiler()
275 cc = new_compiler()
260 if hasfunction(cc, 'inotify_add_watch'):
276 if hasfunction(cc, 'inotify_add_watch'):
261 extmodules.append(Extension('hgext.inotify.linux._inotify',
277 inotify = Extension('hgext.inotify.linux._inotify',
262 ['hgext/inotify/linux/_inotify.c']))
278 ['hgext/inotify/linux/_inotify.c'])
279 inotify.optional = True
280 extmodules.append(inotify)
263 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
281 packages.extend(['hgext.inotify', 'hgext.inotify.linux'])
264
282
265 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
283 packagedata = {'mercurial': ['locale/*/LC_MESSAGES/hg.mo',
General Comments 0
You need to be logged in to leave comments. Login now