2
0

setup.py 4.3 KB

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