changeset 786:d30a27266b45

Set zip_safe to False if the c speedup module is successfully built. Closes #252.
author jonas
date Sun, 03 Aug 2008 20:15:13 +0000
parents 64bf70856f02
children 422a9dd01e9f
files setup.py
diffstat 1 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py
+++ b/setup.py
@@ -20,9 +20,11 @@
 import os
 try:
     from setuptools import setup, Extension, Feature
+    from setuptools.command.bdist_egg import bdist_egg
 except ImportError:
     from distutils.core import setup, Extension
     Feature = None
+    bdist_egg = None
 import sys
 
 sys.path.append(os.path.join('doc', 'common'))
@@ -31,6 +33,7 @@
 except ImportError:
     build_doc = test_doc = None
 
+_speedup_available = False
 
 class optional_build_ext(build_ext):
     # This class allows C extension building to fail.
@@ -43,6 +46,8 @@
     def build_extension(self, ext):
         try:
             build_ext.build_extension(self, ext)
+            global _speedup_available
+            _speedup_available = True
         except CCompilerError, x:
             self._unavailable()
 
@@ -65,6 +70,19 @@
 else:
     speedups = None
 
+
+# Setuptools need some help figuring out if the egg is "zip_safe" or not
+if bdist_egg:
+    class my_bdist_egg(bdist_egg):
+        def zip_safe(self):
+            return not _speedup_available and bdist_egg.zip_safe(self)
+
+
+cmdclass = {'build_doc': build_doc, 'test_doc': test_doc,
+            'build_ext': optional_build_ext}
+if bdist_egg:
+    cmdclass['bdist_egg'] = my_bdist_egg
+
 setup(
     name = 'Genshi',
     version = '0.6',
@@ -79,7 +97,6 @@
     license = 'BSD',
     url = 'http://genshi.edgewall.org/',
     download_url = 'http://genshi.edgewall.org/wiki/Download',
-    zip_safe = True,
 
     classifiers = [
         'Development Status :: 4 - Beta',
@@ -112,6 +129,5 @@
     """,
 
     features = {'speedups': speedups},
-    cmdclass = {'build_doc': build_doc, 'test_doc': test_doc,
-                'build_ext': optional_build_ext}
+    cmdclass = cmdclass
 )
Copyright (C) 2012-2017 Edgewall Software