Edgewall Software

Ticket #165: genshi.diff

File genshi.diff, 3.8 KB (added by njriley+genshi.edgewall.org@…, 16 years ago)

display exception and remove warnings if setuptools absent

  • setup.py

     
    1414
    1515from distutils.cmd import Command
    1616from distutils.command.build_ext import build_ext
    17 from distutils.errors import CCompilerError, DistutilsPlatformError
     17from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
    1818import doctest
    1919from glob import glob
    2020import os
     
    2222    from setuptools import setup, Extension, Feature
    2323except ImportError:
    2424    from distutils.core import setup, Extension
    25     Feature = None
     25    extra = {}
     26else:
     27    speedups = Feature(
     28        "optionial C speed-enhancements",
     29        standard = True,
     30        ext_modules = [
     31            Extension('genshi._speedups', ['genshi/_speedups.c']),
     32        ],
     33    )
     34
     35    extra = dict(
     36        zip_safe = True,
     37        extras_require = {
     38            'i18n': ['Babel>=0.8'],
     39            'plugin': ['setuptools>=0.6a2']
     40        },
     41        entry_points = """
     42        [babel.extractors]
     43        genshi = genshi.filters.i18n:extract[i18n]
     44
     45        [python.templating.engines]
     46        genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
     47        genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
     48        genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin]
     49        """,
     50        test_suite = 'genshi.tests.suite',
     51        features = {'speedups': speedups}
     52    )
    2653import sys
    2754
    2855sys.path.append(os.path.join('doc', 'common'))
     
    3764    def run(self):
    3865        try:
    3966            build_ext.run(self)
    40         except DistutilsPlatformError:
    41             self._unavailable()
     67        except DistutilsPlatformError, e:
     68            self._unavailable(e)
    4269
    4370    def build_extension(self, ext):
    4471        try:
    4572            build_ext.build_extension(self, ext)
    46         except CCompilerError, x:
    47             self._unavailable()
     73        except (CCompilerError, DistutilsExecError), e:
     74            self._unavailable(e)
    4875
    49     def _unavailable(self):
    50         print '*' * 70
    51         print """WARNING:
     76    def _unavailable(self, e):
     77        print >> sys.stderr, '*' * 80
     78        print >> sys.stderr, """WARNING:
    5279An optional C extension could not be compiled, speedups will not be
    5380available."""
    54         print '*' * 70
     81        print >> sys.stderr
     82        print >> sys.stderr, e
     83        print >> sys.stderr, '*' * 80
    5584
    5685
    57 if Feature:
    58     speedups = Feature(
    59         "optionial C speed-enhancements",
    60         standard = True,
    61         ext_modules = [
    62             Extension('genshi._speedups', ['genshi/_speedups.c']),
    63         ],
    64     )
    65 else:
    66     speedups = None
    67 
    6886setup(
    6987    name = 'Genshi',
    7088    version = '0.5',
     
    7997    license = 'BSD',
    8098    url = 'http://genshi.edgewall.org/',
    8199    download_url = 'http://genshi.edgewall.org/wiki/Download',
    82     zip_safe = True,
    83100
    84101    classifiers = [
    85102        'Development Status :: 4 - Beta',
     
    95112    ],
    96113    keywords = ['python.templating.engines'],
    97114    packages = ['genshi', 'genshi.filters', 'genshi.template'],
    98     test_suite = 'genshi.tests.suite',
    99115
    100     extras_require = {
    101         'i18n': ['Babel>=0.8'],
    102         'plugin': ['setuptools>=0.6a2']
    103     },
    104     entry_points = """
    105     [babel.extractors]
    106     genshi = genshi.filters.i18n:extract[i18n]
    107    
    108     [python.templating.engines]
    109     genshi = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
    110     genshi-markup = genshi.template.plugin:MarkupTemplateEnginePlugin[plugin]
    111     genshi-text = genshi.template.plugin:TextTemplateEnginePlugin[plugin]
    112     """,
    113 
    114     features = {'speedups': speedups},
    115116    cmdclass = {'build_doc': build_doc, 'test_doc': test_doc,
    116                 'build_ext': optional_build_ext}
     117                'build_ext': optional_build_ext},
     118    **extra
    117119)