setup.py 1.6 KB

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