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