Initial import to Tizen
[profile/ivi/python-zope.interface.git] / build_ext_2.py
1 import sys
2 from distutils.errors import (CCompilerError, DistutilsExecError, 
3                               DistutilsPlatformError)
4 try:
5     from setuptools.command.build_ext import build_ext
6 except ImportError:
7     from distutils.command.build_ext import build_ext
8     
9
10 class optional_build_ext(build_ext):
11     """This class subclasses build_ext and allows
12        the building of C extensions to fail.
13     """
14     def run(self):
15         try:
16             build_ext.run(self)
17         
18         except DistutilsPlatformError, e:
19             self._unavailable(e)
20
21     def build_extension(self, ext):
22         try:
23             build_ext.build_extension(self, ext)
24         
25         except (CCompilerError, DistutilsExecError), e:
26             self._unavailable(e)
27
28     def _unavailable(self, e):
29         print >> sys.stderr, '*' * 80
30         print >> sys.stderr, """WARNING:
31
32         An optional code optimization (C extension) could not be compiled.
33
34         Optimizations for this package will not be available!"""
35         print >> sys.stderr
36         print >> sys.stderr, e
37         print >> sys.stderr, '*' * 80
38