Index: Doc/distutils/setupscript.rst =================================================================== --- Doc/distutils/setupscript.rst (Revision 70616) +++ Doc/distutils/setupscript.rst (Arbeitskopie) @@ -334,6 +334,10 @@ There are still some other options which can be used to handle special cases. +The :option:`optional` option is a boolean; if it is true, that specifies that +a build failure in the extension should not abort the build process, but simply +not install the failing extension. + The :option:`extra_objects` option is a list of object files to be passed to the linker. These files must not have extensions, as the default extension for the compiler is used. Index: Lib/distutils/command/build_ext.py =================================================================== --- Lib/distutils/command/build_ext.py (Revision 70616) +++ Lib/distutils/command/build_ext.py (Arbeitskopie) @@ -476,7 +476,13 @@ self.check_extensions_list(self.extensions) for ext in self.extensions: - self.build_extension(ext) + try: + self.build_extension(ext) + except (CCompilerError, DistutilsError), why: + if not ext.optional: + raise + self.warn('building extension "%s" failed: %s' % + (ext.name, why)) def build_extension(self, ext): sources = ext.sources Index: Lib/distutils/extension.py =================================================================== --- Lib/distutils/extension.py (Revision 70616) +++ Lib/distutils/extension.py (Arbeitskopie) @@ -101,6 +101,7 @@ swig_opts = None, depends=None, language=None, + optional=None, **kw # To catch unknown keywords ): assert type(name) is StringType, "'name' must be a string" @@ -123,6 +124,7 @@ self.swig_opts = swig_opts or [] self.depends = depends or [] self.language = language + self.optional = optional # If there are unknown keyword options, warn about them if len(kw):