setup.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.2'
  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. scripts = ['bin/dul-receive-pack', 'bin/dul-upload-pack']
  52. if has_setuptools:
  53. setup_kwargs['extras_require'] = {
  54. 'fastimport': ['fastimport'],
  55. 'https': ['urllib3[secure]>=1.24.1'],
  56. 'pgp': ['gpg'],
  57. }
  58. setup_kwargs['install_requires'] = ['urllib3>=1.24.1', 'certifi']
  59. setup_kwargs['include_package_data'] = True
  60. setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
  61. setup_kwargs['tests_require'] = tests_require
  62. setup_kwargs['entry_points'] = {
  63. "console_scripts": [
  64. "dulwich=dulwich.cli:main",
  65. ]}
  66. else:
  67. scripts.append('bin/dulwich')
  68. with io.open(os.path.join(os.path.dirname(__file__), "README.rst"),
  69. encoding="utf-8") as f:
  70. description = f.read()
  71. setup(name='dulwich',
  72. author="Jelmer Vernooij",
  73. author_email="jelmer@jelmer.uk",
  74. url="https://www.dulwich.io/",
  75. long_description=description,
  76. description="Python Git Library",
  77. version=dulwich_version_string,
  78. license='Apachev2 or later or GPLv2',
  79. project_urls={
  80. "Bug Tracker": "https://github.com/dulwich/dulwich/issues",
  81. "Repository": "https://www.dulwich.io/code/",
  82. "GitHub": "https://github.com/dulwich/dulwich",
  83. },
  84. keywords="git vcs",
  85. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
  86. 'dulwich.contrib'],
  87. package_data={'': ['../docs/tutorial/*.txt']},
  88. scripts=scripts,
  89. ext_modules=ext_modules,
  90. distclass=DulwichDistribution,
  91. classifiers=[
  92. 'Development Status :: 4 - Beta',
  93. 'License :: OSI Approved :: Apache Software License',
  94. 'Programming Language :: Python :: 3.5',
  95. 'Programming Language :: Python :: 3.6',
  96. 'Programming Language :: Python :: 3.7',
  97. 'Programming Language :: Python :: 3.8',
  98. 'Programming Language :: Python :: Implementation :: CPython',
  99. 'Programming Language :: Python :: Implementation :: PyPy',
  100. 'Operating System :: POSIX',
  101. 'Operating System :: Microsoft :: Windows',
  102. 'Topic :: Software Development :: Version Control',
  103. ],
  104. **setup_kwargs
  105. )