2
0

setup.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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
  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. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  13. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  14. # distutils.sysconfig
  15. import subprocess
  16. p = subprocess.Popen(
  17. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  18. stderr=subprocess.PIPE, env={})
  19. out, err = p.communicate()
  20. for line in out.splitlines():
  21. line = line.decode("utf8")
  22. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  23. if (line.startswith('Xcode')
  24. and int(line.split()[1].split('.')[0]) >= 4):
  25. os.environ['ARCHFLAGS'] = ''
  26. tests_require = ['fastimport']
  27. if '__pypy__' not in sys.modules and sys.platform != 'win32':
  28. tests_require.extend([
  29. 'gevent', 'geventhttpclient', 'setuptools>=17.1'])
  30. optional = os.environ.get('CIBUILDWHEEL', '0') != '1'
  31. ext_modules = [
  32. Extension('dulwich._objects', ['dulwich/_objects.c'],
  33. optional=optional),
  34. Extension('dulwich._pack', ['dulwich/_pack.c'],
  35. optional=optional),
  36. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  37. optional=optional),
  38. ]
  39. setup(package_data={'': ['../docs/tutorial/*.txt', 'py.typed']},
  40. ext_modules=ext_modules,
  41. tests_require=tests_require)