2
0

setup.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.9'
  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.21'],
  63. }
  64. setup_kwargs['install_requires'] = ['urllib3>=1.21', '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. with io.open(os.path.join(os.path.dirname(__file__), "README.md"),
  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=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  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 :: 2.7',
  95. 'Programming Language :: Python :: 3.4',
  96. 'Programming Language :: Python :: 3.5',
  97. 'Programming Language :: Python :: 3.6',
  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. )