2
0

setup.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. setup(name='dulwich',
  68. version=dulwich_version_string,
  69. license='Apachev2 or later or GPLv2',
  70. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat',
  71. 'dulwich.contrib'],
  72. package_data={'': ['../docs/tutorial/*.txt']},
  73. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  74. ext_modules=ext_modules,
  75. distclass=DulwichDistribution,
  76. **setup_kwargs
  77. )