2
0

setup.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. except ImportError:
  7. from distutils.core import setup, Extension
  8. from distutils.core import Distribution
  9. dulwich_version_string = '0.10.1a'
  10. include_dirs = []
  11. # Windows MSVC support
  12. import os
  13. import sys
  14. if sys.platform == 'win32':
  15. include_dirs.append('dulwich')
  16. class DulwichDistribution(Distribution):
  17. def is_pure(self):
  18. if self.pure:
  19. return True
  20. def has_ext_modules(self):
  21. return not self.pure
  22. global_options = Distribution.global_options + [
  23. ('pure', None, "use pure Python code instead of C "
  24. "extensions (slower on CPython)")]
  25. pure = False
  26. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  27. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  28. # distutils.sysconfig
  29. import subprocess
  30. p = subprocess.Popen(
  31. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  32. stderr=subprocess.PIPE, env={})
  33. out, err = p.communicate()
  34. for l in out.splitlines():
  35. l = l.decode("utf8")
  36. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  37. if l.startswith('Xcode') and int(l.split()[1].split('.')[0]) >= 4:
  38. os.environ['ARCHFLAGS'] = ''
  39. if sys.version_info[0] == 2:
  40. tests_require = ['fastimport', 'mock']
  41. if not '__pypy__' in sys.modules:
  42. tests_require.extend(['gevent', 'geventhttpclient'])
  43. else:
  44. # fastimport, gevent, geventhttpclient are not available for PY3
  45. # mock only used for test_swift, which requires gevent/geventhttpclient
  46. tests_require = []
  47. if sys.version_info < (2, 7):
  48. tests_require.append('unittest2')
  49. setup(name='dulwich',
  50. description='Python Git Library',
  51. keywords='git',
  52. version=dulwich_version_string,
  53. url='https://samba.org/~jelmer/dulwich',
  54. license='GPLv2 or later',
  55. author='Jelmer Vernooij',
  56. author_email='jelmer@samba.org',
  57. long_description="""
  58. Python implementation of the Git file formats and protocols,
  59. without the need to have git installed.
  60. All functionality is available in pure Python. Optional
  61. C extensions can be built for improved performance.
  62. The project is named after the part of London that Mr. and Mrs. Git live in
  63. in the particular Monty Python sketch.
  64. """,
  65. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat', 'dulwich.contrib'],
  66. package_data={'': ['../docs/tutorial/*.txt']},
  67. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  68. classifiers=[
  69. 'Development Status :: 4 - Beta',
  70. 'License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)',
  71. 'Programming Language :: Python :: 2.6',
  72. 'Programming Language :: Python :: 2.7',
  73. 'Operating System :: POSIX',
  74. 'Topic :: Software Development :: Version Control',
  75. ],
  76. ext_modules=[
  77. Extension('dulwich._objects', ['dulwich/_objects.c'],
  78. include_dirs=include_dirs),
  79. Extension('dulwich._pack', ['dulwich/_pack.c'],
  80. include_dirs=include_dirs),
  81. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  82. include_dirs=include_dirs),
  83. ],
  84. test_suite='dulwich.tests.test_suite',
  85. tests_require=tests_require,
  86. distclass=DulwichDistribution,
  87. include_package_data=True,
  88. )