diff options
author | Chris McDonough <chrism@plope.com> | 2009-05-02 07:42:57 +0000 |
---|---|---|
committer | Chris McDonough <chrism@plope.com> | 2009-05-02 07:42:57 +0000 |
commit | f817711870361f786994f8a739e29c7a050e9d04 (patch) | |
tree | 8fe0415eeebae5a6d5d384709c1cd2042dd1e6e4 | |
parent | 2bc8272e6f3a766a9678d88e16207055d4c83bf9 (diff) | |
download | zope-i18nmessageid-f817711870361f786994f8a739e29c7a050e9d04.tar.gz |
Make compilation of C extension optional.
-rw-r--r-- | setup.py | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -17,12 +17,46 @@ $Id$ """ import os +import sys from setuptools import setup, find_packages, Extension +from distutils.command.build_ext import build_ext +from distutils.errors import CCompilerError +from distutils.errors import DistutilsExecError +from distutils.errors import DistutilsPlatformError def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() +class optional_build_ext(build_ext): + """This class subclasses build_ext and allows + the building of C extensions to fail. + """ + def run(self): + try: + build_ext.run(self) + + except DistutilsPlatformError, e: + self._unavailable(e) + + def build_extension(self, ext): + try: + build_ext.build_extension(self, ext) + + except (CCompilerError, DistutilsExecError), e: + self._unavailable(e) + + def _unavailable(self, e): + print >> sys.stderr, '*' * 80 + print >> sys.stderr, """WARNING: + + An optional code optimization (C extension) could not be compiled. + + Optimizations for this package will not be available!""" + print >> sys.stderr + print >> sys.stderr, e + print >> sys.stderr, '*' * 80 + setup(name='zope.i18nmessageid', version = '3.5.0dev', @@ -61,4 +95,6 @@ setup(name='zope.i18nmessageid', install_requires=['setuptools'], include_package_data = True, zip_safe = False, + cmdclass = {'build_ext':optional_build_ext}, ) + |