2
0

setup.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/usr/bin/python
  2. # encoding: utf-8
  3. # Setup file for dulwich
  4. # Copyright (C) 2008-2016 Jelmer Vernooij <jelmer@jelmer.uk>
  5. try:
  6. from setuptools import setup, Extension
  7. except ImportError:
  8. from distutils.core import setup, Extension
  9. from distutils.core import Distribution
  10. import os
  11. import sys
  12. dulwich_version_string = '0.18.6'
  13. include_dirs = []
  14. # Windows MSVC support
  15. if sys.platform == 'win32' and sys.version_info[:2] < (3, 6):
  16. # Include dulwich/ for fallback stdint.h
  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, "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 line in out.splitlines():
  37. line = line.decode("utf8")
  38. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  39. if (line.startswith('Xcode') and
  40. int(line.split()[1].split('.')[0]) >= 4):
  41. os.environ['ARCHFLAGS'] = ''
  42. tests_require = ['fastimport']
  43. if '__pypy__' not in sys.modules and not sys.platform == 'win32':
  44. tests_require.extend([
  45. 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
  46. ext_modules = [
  47. Extension('dulwich._objects', ['dulwich/_objects.c'],
  48. include_dirs=include_dirs),
  49. Extension('dulwich._pack', ['dulwich/_pack.c'],
  50. include_dirs=include_dirs),
  51. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  52. include_dirs=include_dirs),
  53. ]
  54. if sys.platform == 'win32':
  55. # Win32 setup breaks with non-ascii characters.
  56. author = "Jelmer Vernooij"
  57. else:
  58. author = "Jelmer Vernooij"
  59. setup(name='dulwich',
  60. description='Python Git Library',
  61. keywords='git',
  62. version=dulwich_version_string,
  63. url='https://www.dulwich.io/',
  64. license='Apachev2 or later or GPLv2',
  65. author_email='jelmer@jelmer.uk',
  66. long_description="""
  67. Python implementation of the Git file formats and protocols,
  68. without the need to have git installed.
  69. All functionality is available in pure Python. Optional
  70. C extensions can be built for improved performance.
  71. The project is named after the part of London that Mr. and Mrs. Git live
  72. in in the particular Monty Python sketch.
  73. """,
  74. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
  75. 'dulwich.contrib'],
  76. package_data={'': ['../docs/tutorial/*.txt']},
  77. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  78. classifiers=[
  79. 'Development Status :: 4 - Beta',
  80. 'License :: OSI Approved :: Apache Software License',
  81. 'Programming Language :: Python :: 2.7',
  82. 'Programming Language :: Python :: 3.3',
  83. 'Programming Language :: Python :: 3.4',
  84. 'Programming Language :: Python :: 3.5',
  85. 'Programming Language :: Python :: 3.6',
  86. 'Programming Language :: Python :: Implementation :: CPython',
  87. 'Programming Language :: Python :: Implementation :: PyPy',
  88. 'Operating System :: POSIX',
  89. 'Operating System :: Microsoft :: Windows',
  90. 'Topic :: Software Development :: Version Control',
  91. ],
  92. ext_modules=ext_modules,
  93. test_suite='dulwich.tests.test_suite',
  94. tests_require=tests_require,
  95. distclass=DulwichDistribution,
  96. include_package_data=True,
  97. )