Add --without-speedups option.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 25 Jan 2010 09:10:07 +0000 (10:10 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 25 Jan 2010 09:10:07 +0000 (10:10 +0100)
NEWS
setup.py

diff --git a/NEWS b/NEWS
index 63069b26484e75e730239b0c500599434676c5d5..e0fb9c5555c91724ec11238a6d221b316d9bffff 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,11 @@
 
   * Support custom fields in commits.
 
+ FEATURES
+
+  * --without-speedups option to setup.py to allow building/installing 
+    without the C extensions. (Hal Wine, Jelmer Vernooij)
+
 0.4.1  2010-01-03
 
  FEATURES
index cfb56ffd147050bf5ef7a1d956d4ddb730a1588f..7f87c018e83616e02b73c31db7bc57640b3c65f3 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -2,16 +2,10 @@
 # Setup file for bzr-git
 # Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
 
-from distutils.cmd import Command
-from distutils.command.build_ext import build_ext
-from distutils.errors import CCompilerError, DistutilsPlatformError
 try:
-    from setuptools import setup, Extension, Feature
-    from setuptools.command.bdist_egg import bdist_egg
+    from setuptools import setup, Extension
 except ImportError:
     from distutils.core import setup, Extension
-    Feature = None
-    bdist_egg = None
 
 dulwich_version_string = '0.4.2'
 
@@ -21,62 +15,25 @@ import sys
 if sys.platform == 'win32':
     include_dirs.append('dulwich')
 
-#sys.path.append(os.path.join('doc', 'common'))
+ext_modules = [
+    Extension('dulwich._objects', ['dulwich/_objects.c'],
+              include_dirs=include_dirs),
+    Extension('dulwich._pack', ['dulwich/_pack.c'],
+              include_dirs=include_dirs),
+    ]
 
-_speedup_available = False
-
-class optional_build_ext(build_ext):
-    # This class allows C extension building to fail.
-    def run(self):
-        try:
-            print "trying run"
-            build_ext.run(self)
-        except DistutilsPlatformError, e:
-            self._unavailable(e)
-
-    def build_extension(self, ext):
-        try:
-            print "trying build_extension %s" % (ext,)
-            build_ext.build_extension(self, ext)
-            global _speedup_available
-            _speedup_available = True
-        except CCompilerError, e:
-            self._unavailable(e)
-
-    def _unavailable(self, exc):
-        print('*' * 70)
-        print("""WARNING:
-An optional C extension could not be compiled, speedups will not be
-available.""")
-        print('*' * 70)
-        print(exc)
-
-if Feature:
+try:
+    from setuptools import Feature
+except ImportError:
+    speedups = None
+    mandatory_ext_modules = ext_modules
+else:
+    mandatory_ext_modules = []
     speedups = Feature(
         "optional C speed-enhancements",
         standard = True,
-        ext_modules=[
-            Extension('dulwich._objects', ['dulwich/_objects.c'],
-                      include_dirs=include_dirs),
-            Extension('dulwich._pack', ['dulwich/_pack.c'],
-                      include_dirs=include_dirs),
-            ],
+        ext_modules=ext_modules,
     )
-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_ext': optional_build_ext}
-if bdist_egg:
-    cmdclass['bdist_egg'] = my_bdist_egg
-
 
 
 setup(name='dulwich',
@@ -96,5 +53,5 @@ setup(name='dulwich',
       packages=['dulwich', 'dulwich.tests'],
       scripts=['bin/dulwich', 'bin/dul-daemon'],
       features = {'speedups': speedups},
-      cmdclass = cmdclass,
+      ext_modules = mandatory_ext_modules,
       )