setup.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.19.17'
  17. include_dirs = []
  18. # Windows MSVC support
  19. if sys.platform == 'win32' and sys.version_info[:2] < (3, 6):
  20. # Include dulwich/ for fallback stdint.h
  21. include_dirs.append('dulwich')
  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 not sys.platform == 'win32':
  48. tests_require.extend([
  49. 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
  50. ext_modules = [
  51. Extension('dulwich._objects', ['dulwich/_objects.c'],
  52. include_dirs=include_dirs),
  53. Extension('dulwich._pack', ['dulwich/_pack.c'],
  54. include_dirs=include_dirs),
  55. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  56. include_dirs=include_dirs),
  57. ]
  58. setup_kwargs = {}
  59. if has_setuptools:
  60. setup_kwargs['extras_require'] = {
  61. 'fastimport': ['fastimport'],
  62. 'https': ['urllib3[secure]>=1.24.1'],
  63. 'pgp': ['gpg'],
  64. }
  65. setup_kwargs['install_requires'] = ['urllib3>=1.24.1', 'certifi']
  66. setup_kwargs['include_package_data'] = True
  67. setup_kwargs['test_suite'] = 'dulwich.tests.test_suite'
  68. setup_kwargs['tests_require'] = tests_require
  69. with io.open(os.path.join(os.path.dirname(__file__), "README.rst"),
  70. encoding="utf-8") as f:
  71. description = f.read()
  72. setup(name='dulwich',
  73. author="Jelmer Vernooij",
  74. author_email="jelmer@jelmer.uk",
  75. url="https://www.dulwich.io/",
  76. long_description=description,
  77. description="Python Git Library",
  78. version=dulwich_version_string,
  79. license='Apachev2 or later or GPLv2',
  80. project_urls={
  81. "Bug Tracker": "https://github.com/dulwich/dulwich/issues",
  82. "Repository": "https://www.dulwich.io/code/",
  83. "GitHub": "https://github.com/dulwich/dulwich",
  84. },
  85. keywords="git vcs",
  86. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
  87. 'dulwich.contrib'],
  88. package_data={'': ['../docs/tutorial/*.txt']},
  89. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  90. ext_modules=ext_modules,
  91. distclass=DulwichDistribution,
  92. classifiers=[
  93. 'Development Status :: 4 - Beta',
  94. 'License :: OSI Approved :: Apache Software License',
  95. 'Programming Language :: Python :: 2.7',
  96. 'Programming Language :: Python :: 3.4',
  97. 'Programming Language :: Python :: 3.5',
  98. 'Programming Language :: Python :: 3.6',
  99. 'Programming Language :: Python :: Implementation :: CPython',
  100. 'Programming Language :: Python :: Implementation :: PyPy',
  101. 'Operating System :: POSIX',
  102. 'Operating System :: Microsoft :: Windows',
  103. 'Topic :: Software Development :: Version Control',
  104. ],
  105. **setup_kwargs
  106. )