setup.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/python
  2. # Setup file for bzr-git
  3. # Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
  4. from distutils.cmd import Command
  5. from distutils.command.build_ext import build_ext
  6. from distutils.errors import CCompilerError, DistutilsPlatformError
  7. try:
  8. from setuptools import setup, Extension, Feature
  9. from setuptools.command.bdist_egg import bdist_egg
  10. except ImportError:
  11. from distutils.core import setup, Extension
  12. Feature = None
  13. bdist_egg = None
  14. dulwich_version_string = '0.4.2'
  15. include_dirs = []
  16. # Windows MSVC support
  17. import sys
  18. if sys.platform == 'win32':
  19. include_dirs.append('dulwich')
  20. #sys.path.append(os.path.join('doc', 'common'))
  21. _speedup_available = False
  22. class optional_build_ext(build_ext):
  23. # This class allows C extension building to fail.
  24. def run(self):
  25. try:
  26. print "trying run"
  27. build_ext.run(self)
  28. except DistutilsPlatformError, e:
  29. self._unavailable(e)
  30. def build_extension(self, ext):
  31. try:
  32. print "trying build_extension %s" % (ext,)
  33. build_ext.build_extension(self, ext)
  34. global _speedup_available
  35. _speedup_available = True
  36. except CCompilerError, e:
  37. self._unavailable(e)
  38. def _unavailable(self, exc):
  39. print('*' * 70)
  40. print("""WARNING:
  41. An optional C extension could not be compiled, speedups will not be
  42. available.""")
  43. print('*' * 70)
  44. print(exc)
  45. if Feature:
  46. speedups = Feature(
  47. "optional C speed-enhancements",
  48. standard = True,
  49. ext_modules=[
  50. Extension('dulwich._objects', ['dulwich/_objects.c'],
  51. include_dirs=include_dirs),
  52. Extension('dulwich._pack', ['dulwich/_pack.c'],
  53. include_dirs=include_dirs),
  54. ],
  55. )
  56. else:
  57. speedups = None
  58. # Setuptools need some help figuring out if the egg is "zip_safe" or not
  59. if bdist_egg:
  60. class my_bdist_egg(bdist_egg):
  61. def zip_safe(self):
  62. return not _speedup_available and bdist_egg.zip_safe(self)
  63. cmdclass = {'build_ext': optional_build_ext}
  64. if bdist_egg:
  65. cmdclass['bdist_egg'] = my_bdist_egg
  66. setup(name='dulwich',
  67. description='Pure-Python Git Library',
  68. keywords='git',
  69. version=dulwich_version_string,
  70. url='http://samba.org/~jelmer/dulwich',
  71. download_url='http://samba.org/~jelmer/dulwich/dulwich-%s.tar.gz' % dulwich_version_string,
  72. license='GPLv2 or later',
  73. author='Jelmer Vernooij',
  74. author_email='jelmer@samba.org',
  75. long_description="""
  76. Simple Pure-Python implementation of the Git file formats and
  77. protocols. Dulwich is the place where Mr. and Mrs. Git live
  78. in one of the Monty Python sketches.
  79. """,
  80. packages=['dulwich', 'dulwich.tests'],
  81. scripts=['bin/dulwich', 'bin/dul-daemon'],
  82. features = {'speedups': speedups},
  83. cmdclass = cmdclass,
  84. )