setup.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/python3
  2. # encoding: utf-8
  3. # Setup file for dulwich
  4. # Copyright (C) 2008-2022 Jelmer Vernooij <jelmer@jelmer.uk>
  5. from setuptools import setup, Extension, Distribution
  6. import os
  7. import sys
  8. if sys.version_info < (3, 6):
  9. raise Exception(
  10. 'Dulwich only supports Python 3.6 and later. '
  11. 'For 2.7 support, please install a version prior to 0.20')
  12. dulwich_version_string = '0.20.46'
  13. class DulwichDistribution(Distribution):
  14. def is_pure(self):
  15. if self.pure:
  16. return True
  17. def has_ext_modules(self):
  18. return not self.pure
  19. global_options = Distribution.global_options + [
  20. ('pure', None, "use pure Python code instead of C "
  21. "extensions (slower on CPython)")]
  22. pure = False
  23. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  24. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  25. # distutils.sysconfig
  26. import subprocess
  27. p = subprocess.Popen(
  28. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  29. stderr=subprocess.PIPE, env={})
  30. out, err = p.communicate()
  31. for line in out.splitlines():
  32. line = line.decode("utf8")
  33. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  34. if (line.startswith('Xcode')
  35. and int(line.split()[1].split('.')[0]) >= 4):
  36. os.environ['ARCHFLAGS'] = ''
  37. tests_require = ['fastimport']
  38. if '__pypy__' not in sys.modules and sys.platform != 'win32':
  39. tests_require.extend([
  40. 'gevent', 'geventhttpclient', 'setuptools>=17.1'])
  41. ext_modules = [
  42. Extension('dulwich._objects', ['dulwich/_objects.c']),
  43. Extension('dulwich._pack', ['dulwich/_pack.c']),
  44. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c']),
  45. ]
  46. scripts = ['bin/dul-receive-pack', 'bin/dul-upload-pack']
  47. setup(keywords="git vcs",
  48. package_data={'': ['../docs/tutorial/*.txt', 'py.typed']},
  49. scripts=scripts,
  50. ext_modules=ext_modules,
  51. zip_safe=False,
  52. distclass=DulwichDistribution, # type: ignore
  53. include_package_data=True,
  54. tests_require=tests_require)