浏览代码

Add --without-speedups option.

Jelmer Vernooij 15 年之前
父节点
当前提交
bed597191e
共有 2 个文件被更改,包括 29 次插入9 次删除
  1. 5 0
      NEWS
  2. 24 9
      setup.py

+ 5 - 0
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

+ 24 - 9
setup.py

@@ -3,10 +3,9 @@
 # Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
 
 try:
-    from setuptools import setup
+    from setuptools import setup, Extension
 except ImportError:
-    from distutils.core import setup
-from distutils.extension import Extension
+    from distutils.core import setup, Extension
 
 dulwich_version_string = '0.4.2'
 
@@ -16,6 +15,26 @@ import sys
 if sys.platform == 'win32':
     include_dirs.append('dulwich')
 
+ext_modules = [
+    Extension('dulwich._objects', ['dulwich/_objects.c'],
+              include_dirs=include_dirs),
+    Extension('dulwich._pack', ['dulwich/_pack.c'],
+              include_dirs=include_dirs),
+    ]
+
+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=ext_modules,
+    )
+
 
 setup(name='dulwich',
       description='Pure-Python Git Library',
@@ -33,10 +52,6 @@ setup(name='dulwich',
       """,
       packages=['dulwich', 'dulwich.tests'],
       scripts=['bin/dulwich', 'bin/dul-daemon'],
-      ext_modules=[
-          Extension('dulwich._objects', ['dulwich/_objects.c'],
-                    include_dirs=include_dirs),
-          Extension('dulwich._pack', ['dulwich/_pack.c'],
-                    include_dirs=include_dirs),
-          ],
+      features = {'speedups': speedups},
+      ext_modules = mandatory_ext_modules,
       )