2
0

setup.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 io
  14. import os
  15. import sys
  16. dulwich_version_string = '0.20.0'
  17. class DulwichDistribution(Distribution):
  18. def is_pure(self):
  19. if self.pure:
  20. return True
  21. def has_ext_modules(self):
  22. return not self.pure
  23. global_options = Distribution.global_options + [
  24. ('pure', None, "use pure Python code instead of C "
  25. "extensions (slower on CPython)")]
  26. pure = False
  27. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  28. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  29. # distutils.sysconfig
  30. import subprocess
  31. p = subprocess.Popen(
  32. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  33. stderr=subprocess.PIPE, env={})
  34. out, err = p.communicate()
  35. for line in out.splitlines():
  36. line = line.decode("utf8")
  37. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  38. if (line.startswith('Xcode') and
  39. int(line.split()[1].split('.')[0]) >= 4):
  40. os.environ['ARCHFLAGS'] = ''
  41. tests_require = ['fastimport']
  42. if '__pypy__' not in sys.modules and not sys.platform == 'win32':
  43. tests_require.extend([
  44. 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
  45. ext_modules = [
  46. Extension('dulwich._objects', ['dulwich/_objects.c']),
  47. Extension('dulwich._pack', ['dulwich/_pack.c']),
  48. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c']),
  49. ]
  50. setup_kwargs = {}
  51. if has_setuptools:
  52. setup_kwargs['extras_require'] = {
  53. 'fastimport': ['fastimport'],
  54. 'https': ['urllib3[secure]>=1.24.1'],
  55. 'pgp': ['gpg'],
  56. }
  57. setup_kwargs['install_requires'] = ['urllib3>=1.24.1', 'certifi']
  58. setup_kwargs['include_package_data'] = True
  59. setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
  60. setup_kwargs['tests_require'] = tests_require
  61. with io.open(os.path.join(os.path.dirname(__file__), "README.rst"),
  62. encoding="utf-8") as f:
  63. description = f.read()
  64. setup(name='dulwich',
  65. author="Jelmer Vernooij",
  66. author_email="jelmer@jelmer.uk",
  67. url="https://www.dulwich.io/",
  68. long_description=description,
  69. description="Python Git Library",
  70. version=dulwich_version_string,
  71. license='Apachev2 or later or GPLv2',
  72. project_urls={
  73. "Bug Tracker": "https://github.com/dulwich/dulwich/issues",
  74. "Repository": "https://www.dulwich.io/code/",
  75. "GitHub": "https://github.com/dulwich/dulwich",
  76. },
  77. keywords="git vcs",
  78. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
  79. 'dulwich.contrib'],
  80. package_data={'': ['../docs/tutorial/*.txt']},
  81. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  82. ext_modules=ext_modules,
  83. distclass=DulwichDistribution,
  84. classifiers=[
  85. 'Development Status :: 4 - Beta',
  86. 'License :: OSI Approved :: Apache Software License',
  87. 'Programming Language :: Python :: 3.4',
  88. 'Programming Language :: Python :: 3.5',
  89. 'Programming Language :: Python :: 3.6',
  90. 'Programming Language :: Python :: Implementation :: CPython',
  91. 'Programming Language :: Python :: Implementation :: PyPy',
  92. 'Operating System :: POSIX',
  93. 'Operating System :: Microsoft :: Windows',
  94. 'Topic :: Software Development :: Version Control',
  95. ],
  96. **setup_kwargs
  97. )