# 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
- 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
- from distutils.extension import Extension
+ from distutils.core import setup, Extension
- Feature = None
- bdist_egg = None
dulwich_version_string = '0.4.2'
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',
description='Pure-Python Git Library',
""",
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},
- cmdclass = cmdclass,
++ ext_modules = mandatory_ext_modules,
)