setup.py 2.1 KB

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