setup.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/python
  2. # Setup file for dulwich
  3. # Copyright (C) 2008-2011 Jelmer Vernooij <jelmer@samba.org>
  4. try:
  5. from setuptools import setup, Extension
  6. has_setuptools = True
  7. except ImportError:
  8. from distutils.core import setup, Extension
  9. has_setuptools = False
  10. from distutils.core import Distribution
  11. dulwich_version_string = '0.9.1'
  12. include_dirs = []
  13. # Windows MSVC support
  14. import os
  15. import sys
  16. if sys.platform == 'win32':
  17. include_dirs.append('dulwich')
  18. class DulwichDistribution(Distribution):
  19. def is_pure(self):
  20. if self.pure:
  21. return True
  22. def has_ext_modules(self):
  23. return not self.pure and not '__pypy__' in sys.modules
  24. global_options = Distribution.global_options + [
  25. ('pure', None, "use pure Python code instead of C "
  26. "extensions (slower on CPython)")]
  27. pure = False
  28. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  29. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  30. # distutils.sysconfig
  31. import subprocess
  32. p = subprocess.Popen(
  33. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  34. stderr=subprocess.PIPE, env={})
  35. out, err = p.communicate()
  36. for l in out.splitlines():
  37. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  38. if l.startswith('Xcode') and int(l.split()[1].split('.')[0]) >= 4:
  39. os.environ['ARCHFLAGS'] = ''
  40. setup_kwargs = {}
  41. if has_setuptools:
  42. setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
  43. setup(name='dulwich',
  44. description='Python Git Library',
  45. keywords='git',
  46. version=dulwich_version_string,
  47. url='http://samba.org/~jelmer/dulwich',
  48. license='GPLv2 or later',
  49. author='Jelmer Vernooij',
  50. author_email='jelmer@samba.org',
  51. long_description="""
  52. Simple Python implementation of the Git file formats and
  53. protocols. Dulwich is the place where Mr. and Mrs. Git live
  54. in one of the Monty Python sketches.
  55. All functionality is available in pure Python, but (optional)
  56. C extensions are also available for better performance.
  57. """,
  58. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat'],
  59. scripts=['bin/dulwich', 'bin/dul-daemon', 'bin/dul-web', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  60. ext_modules=[
  61. Extension('dulwich._objects', ['dulwich/_objects.c'],
  62. include_dirs=include_dirs),
  63. Extension('dulwich._pack', ['dulwich/_pack.c'],
  64. include_dirs=include_dirs),
  65. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  66. include_dirs=include_dirs),
  67. ],
  68. distclass=DulwichDistribution,
  69. **setup_kwargs
  70. )