setup.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. has_setuptools = False
  10. else:
  11. has_setuptools = True
  12. from distutils.core import Distribution
  13. import os
  14. import sys
  15. dulwich_version_string = '0.19.1'
  16. include_dirs = []
  17. # Windows MSVC support
  18. if sys.platform == 'win32' and sys.version_info[:2] < (3, 6):
  19. # Include dulwich/ for fallback stdint.h
  20. include_dirs.append('dulwich')
  21. class DulwichDistribution(Distribution):
  22. def is_pure(self):
  23. if self.pure:
  24. return True
  25. def has_ext_modules(self):
  26. return not self.pure
  27. global_options = Distribution.global_options + [
  28. ('pure', None, "use pure Python code instead of C "
  29. "extensions (slower on CPython)")]
  30. pure = False
  31. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  32. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  33. # distutils.sysconfig
  34. import subprocess
  35. p = subprocess.Popen(
  36. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  37. stderr=subprocess.PIPE, env={})
  38. out, err = p.communicate()
  39. for line in out.splitlines():
  40. line = line.decode("utf8")
  41. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  42. if (line.startswith('Xcode') and
  43. int(line.split()[1].split('.')[0]) >= 4):
  44. os.environ['ARCHFLAGS'] = ''
  45. tests_require = ['fastimport']
  46. if '__pypy__' not in sys.modules and not sys.platform == 'win32':
  47. tests_require.extend([
  48. 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
  49. ext_modules = [
  50. Extension('dulwich._objects', ['dulwich/_objects.c'],
  51. include_dirs=include_dirs),
  52. Extension('dulwich._pack', ['dulwich/_pack.c'],
  53. include_dirs=include_dirs),
  54. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  55. include_dirs=include_dirs),
  56. ]
  57. setup_kwargs = {}
  58. if has_setuptools:
  59. setup_kwargs['extras_require'] = {'fastimport': ['fastimport']}
  60. setup_kwargs['install_requires'] = ['urllib3[secure]>=1.21']
  61. setup_kwargs['include_package_data'] = True
  62. setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
  63. setup_kwargs['tests_require'] = tests_require
  64. if sys.platform == 'win32':
  65. # Win32 setup breaks with non-ascii characters.
  66. author = "Jelmer Vernooij"
  67. else:
  68. author = "Jelmer Vernooij"
  69. setup(name='dulwich',
  70. description='Python Git Library',
  71. keywords='git',
  72. version=dulwich_version_string,
  73. url='https://www.dulwich.io/',
  74. license='Apachev2 or later or GPLv2',
  75. author_email='jelmer@jelmer.uk',
  76. long_description="""
  77. Python implementation of the Git file formats and protocols,
  78. without the need to have git installed.
  79. All functionality is available in pure Python. Optional
  80. C extensions can be built for improved performance.
  81. The project is named after the part of London that Mr. and Mrs. Git live
  82. in in the particular Monty Python sketch.
  83. """,
  84. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
  85. 'dulwich.contrib'],
  86. package_data={'': ['../docs/tutorial/*.txt']},
  87. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  88. classifiers=[
  89. 'Development Status :: 4 - Beta',
  90. 'License :: OSI Approved :: Apache Software License',
  91. 'Programming Language :: Python :: 2.7',
  92. 'Programming Language :: Python :: 3.3',
  93. 'Programming Language :: Python :: 3.4',
  94. 'Programming Language :: Python :: 3.5',
  95. 'Programming Language :: Python :: 3.6',
  96. 'Programming Language :: Python :: Implementation :: CPython',
  97. 'Programming Language :: Python :: Implementation :: PyPy',
  98. 'Operating System :: POSIX',
  99. 'Operating System :: Microsoft :: Windows',
  100. 'Topic :: Software Development :: Version Control',
  101. ],
  102. ext_modules=ext_modules,
  103. distclass=DulwichDistribution,
  104. **setup_kwargs
  105. )