setup.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/python3
  2. # Setup file for dulwich
  3. # Copyright (C) 2008-2022 Jelmer Vernooij <jelmer@jelmer.uk>
  4. from setuptools import setup, Extension
  5. import os
  6. import sys
  7. if sys.version_info < (3, 6):
  8. raise Exception(
  9. 'Dulwich only supports Python 3.6 and later. '
  10. 'For 2.7 support, please install a version prior to 0.20')
  11. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  12. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  13. # distutils.sysconfig
  14. import subprocess
  15. p = subprocess.Popen(
  16. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  17. stderr=subprocess.PIPE, env={})
  18. out, err = p.communicate()
  19. for line in out.splitlines():
  20. line = line.decode("utf8")
  21. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  22. if (line.startswith('Xcode')
  23. and int(line.split()[1].split('.')[0]) >= 4):
  24. os.environ['ARCHFLAGS'] = ''
  25. tests_require = ['fastimport']
  26. if '__pypy__' not in sys.modules and sys.platform != 'win32':
  27. tests_require.extend([
  28. 'gevent', 'geventhttpclient', 'setuptools>=17.1'])
  29. optional = os.environ.get('CIBUILDWHEEL', '0') != '1'
  30. ext_modules = [
  31. Extension('dulwich._objects', ['dulwich/_objects.c'],
  32. optional=optional),
  33. Extension('dulwich._pack', ['dulwich/_pack.c'],
  34. optional=optional),
  35. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  36. optional=optional),
  37. ]
  38. # Ideally, setuptools would just provide a way to do this
  39. if '--pure' in sys.argv:
  40. sys.argv.remove('--pure')
  41. ext_modules = []
  42. setup(package_data={'': ['../docs/tutorial/*.txt', 'py.typed']},
  43. ext_modules=ext_modules,
  44. tests_require=tests_require)