Edgewall Software

Ticket #252: smarter_zip_safe.patch

File smarter_zip_safe.patch, 1.8 KB (added by jonas, 15 years ago)
  • setup.py

     
    2020import os
    2121try:
    2222    from setuptools import setup, Extension, Feature
     23    from setuptools.command.bdist_egg import bdist_egg
    2324except ImportError:
    2425    from distutils.core import setup, Extension
    2526    Feature = None
     27    bdist_egg = None
    2628import sys
    2729
    2830sys.path.append(os.path.join('doc', 'common'))
     
    3133except ImportError:
    3234    build_doc = test_doc = None
    3335
     36_speedup_available = True
    3437
    3538class optional_build_ext(build_ext):
    3639    # This class allows C extension building to fail.
     
    4750            self._unavailable()
    4851
    4952    def _unavailable(self):
     53        global _speedup_available
     54        _speedup_available = False
    5055        print '*' * 70
    5156        print """WARNING:
    5257An optional C extension could not be compiled, speedups will not be
     
    6570else:
    6671    speedups = None
    6772
     73
     74# Setuptools need some help figuring out if the egg is "zip_safe" or not
     75if bdist_egg:
     76    class my_bdist_egg(bdist_egg):
     77        def zip_safe(self):
     78            return not _speedup_available and bdist_egg.zip_safe(self)
     79
     80
     81cmdclass = {'build_doc': build_doc, 'test_doc': test_doc,
     82            'build_ext': optional_build_ext}
     83if bdist_egg:
     84    cmdclass['bdist_egg'] = my_bdist_egg
     85
    6886setup(
    6987    name = 'Genshi',
    7088    version = '0.6',
     
    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',
     
    112129    """,
    113130
    114131    features = {'speedups': speedups},
    115     cmdclass = {'build_doc': build_doc, 'test_doc': test_doc,
    116                 'build_ext': optional_build_ext}
     132    cmdclass = cmdclass
    117133)