2
0

setup.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.8.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
  24. global_options = Distribution.global_options + [
  25. ('pure', None,
  26. "use pure (slower) Python code instead of C extensions")]
  27. pure = False
  28. def runcmd(cmd, env):
  29. import subprocess
  30. p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
  31. stderr=subprocess.PIPE, env=env)
  32. out, err = p.communicate()
  33. err = [e for e in err.splitlines()
  34. if not e.startswith('Not trusting file') \
  35. and not e.startswith('warning: Not importing')]
  36. if err:
  37. return ''
  38. return out
  39. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  40. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  41. # distutils.sysconfig
  42. version = runcmd(['/usr/bin/xcodebuild', '-version'], {}).splitlines()[0]
  43. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  44. if (version.startswith('Xcode') and
  45. int(version.split()[1].split('.')[0]) >= 4):
  46. os.environ['ARCHFLAGS'] = ''
  47. setup_kwargs = {}
  48. if has_setuptools:
  49. setup_kwargs['test_suite'] = 'dulwich.tests'
  50. setup(name='dulwich',
  51. description='Python Git Library',
  52. keywords='git',
  53. version=dulwich_version_string,
  54. url='http://samba.org/~jelmer/dulwich',
  55. download_url='http://samba.org/~jelmer/dulwich/dulwich-%s.tar.gz' % dulwich_version_string,
  56. license='GPLv2 or later',
  57. author='Jelmer Vernooij',
  58. author_email='jelmer@samba.org',
  59. long_description="""
  60. Simple Python implementation of the Git file formats and
  61. protocols. Dulwich is the place where Mr. and Mrs. Git live
  62. in one of the Monty Python sketches.
  63. All functionality is available in pure Python, but (optional)
  64. C extensions are also available for better performance.
  65. """,
  66. packages=['dulwich', 'dulwich.tests'],
  67. scripts=['bin/dulwich', 'bin/dul-daemon', 'bin/dul-web'],
  68. ext_modules = [
  69. Extension('dulwich._objects', ['dulwich/_objects.c'],
  70. include_dirs=include_dirs),
  71. Extension('dulwich._pack', ['dulwich/_pack.c'],
  72. include_dirs=include_dirs),
  73. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  74. include_dirs=include_dirs),
  75. ],
  76. distclass=DulwichDistribution,
  77. **setup_kwargs
  78. )