setup.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.4'
  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.
  54. All functionality is available in pure Python. Optional
  55. C extensions can be built for improved performance.
  56. Dulwich takes its name from the area in London where the friendly
  57. Mr. and Mrs. Git once attended a cocktail party.
  58. """,
  59. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat'],
  60. scripts=['bin/dulwich', 'bin/dul-daemon', 'bin/dul-web', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  61. ext_modules=[
  62. Extension('dulwich._objects', ['dulwich/_objects.c'],
  63. include_dirs=include_dirs),
  64. Extension('dulwich._pack', ['dulwich/_pack.c'],
  65. include_dirs=include_dirs),
  66. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  67. include_dirs=include_dirs),
  68. ],
  69. distclass=DulwichDistribution,
  70. **setup_kwargs
  71. )