setup.py 3.9 KB

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