[PATCH 1 of 1] setup: ignore failure to build optional inotify extension

Nicolas Dumazet nicdumz at gmail.com
Wed Jun 23 10:29:10 CDT 2010


Hello!

I like the overall idea.

2010/6/23  <cboos at neuf.fr>:
>
> +class hgbuildext(build_ext):
> +
> +    def build_extensions(self):
> +        # First, sanity-check the 'extensions' list
> +        self.check_extensions_list(self.extensions)
> +
> +        for ext in self.extensions:
> +            try:
> +                self.build_extension(ext)
> +            except CCompilerError:
> +                if not hasattr(ext, 'optional') or not ext.optional:
> +                    raise
> +                log.warn("Failed to build optional extension '%s' (skipping)",
> +                         ext.name)
> +

What about "simply" extending self.build_extension? The problem with
adapting an existing method is that we'll run into problems if for
some reasons the distutils gurus change the logic of build_extensions
and add more stuff in there.

So :


  def build_extension(self, extension):
    try:
      super(hgbuildext, self).build_extension(extension)
    except CCompilerError:
      # catch here and ignore if "optional"


Isnt it better?

Regards,
-Nicolas.

>  class hgbuildpy(build_py):
>
>     def finalize_options(self):
> @@ -232,6 +250,7 @@
>                 yield module
>
>  cmdclass = {'build_mo': hgbuildmo,
> +            'build_ext': hgbuildext,
>             'build_py': hgbuildpy}
>
>  packages = ['mercurial', 'mercurial.hgweb', 'hgext', 'hgext.convert',
> @@ -256,10 +275,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',
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>



-- 
Nicolas Dumazet — NicDumZ


More information about the Mercurial-devel mailing list