2
0

setup.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/usr/bin/python
  2. # encoding: utf-8
  3. # Setup file for dulwich
  4. # Copyright (C) 2008-2016 Jelmer Vernooij <jelmer@jelmer.uk>
  5. try:
  6. from setuptools import setup, Extension
  7. except ImportError:
  8. from distutils.core import setup, Extension
  9. from distutils.core import Distribution
  10. dulwich_version_string = '0.17.3'
  11. include_dirs = []
  12. # Windows MSVC support
  13. import os
  14. import sys
  15. if sys.platform == 'win32':
  16. include_dirs.append('dulwich')
  17. class DulwichDistribution(Distribution):
  18. def is_pure(self):
  19. if self.pure:
  20. return True
  21. def has_ext_modules(self):
  22. return not self.pure
  23. global_options = Distribution.global_options + [
  24. ('pure', None, "use pure Python code instead of C "
  25. "extensions (slower on CPython)")]
  26. pure = False
  27. if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
  28. # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
  29. # distutils.sysconfig
  30. import subprocess
  31. p = subprocess.Popen(
  32. ['/usr/bin/xcodebuild', '-version'], stdout=subprocess.PIPE,
  33. stderr=subprocess.PIPE, env={})
  34. out, err = p.communicate()
  35. for l in out.splitlines():
  36. l = l.decode("utf8")
  37. # Also parse only first digit, because 3.2.1 can't be parsed nicely
  38. if l.startswith('Xcode') and int(l.split()[1].split('.')[0]) >= 4:
  39. os.environ['ARCHFLAGS'] = ''
  40. tests_require = ['fastimport']
  41. if not '__pypy__' in sys.modules and not sys.platform == 'win32':
  42. tests_require.extend([
  43. 'gevent', 'geventhttpclient', 'mock', 'setuptools>=17.1'])
  44. if sys.version_info[0] > 2 and sys.platform == 'win32':
  45. # C Modules don't build for python3 windows, and prevent tests from running
  46. ext_modules = []
  47. else:
  48. ext_modules = [
  49. Extension('dulwich._objects', ['dulwich/_objects.c'],
  50. include_dirs=include_dirs),
  51. Extension('dulwich._pack', ['dulwich/_pack.c'],
  52. include_dirs=include_dirs),
  53. Extension('dulwich._diff_tree', ['dulwich/_diff_tree.c'],
  54. include_dirs=include_dirs),
  55. ]
  56. setup(name='dulwich',
  57. description='Python Git Library',
  58. keywords='git',
  59. version=dulwich_version_string,
  60. url='https://www.dulwich.io/',
  61. license='Apachev2 or later or GPLv2',
  62. author='Jelmer Vernooij',
  63. author_email='jelmer@jelmer.uk',
  64. long_description="""
  65. Python implementation of the Git file formats and protocols,
  66. without the need to have git installed.
  67. All functionality is available in pure Python. Optional
  68. C extensions can be built for improved performance.
  69. The project is named after the part of London that Mr. and Mrs. Git live in
  70. in the particular Monty Python sketch.
  71. """,
  72. packages=['dulwich', 'dulwich.tests', 'dulwich.tests.compat', 'dulwich.contrib'],
  73. package_data={'': ['../docs/tutorial/*.txt']},
  74. scripts=['bin/dulwich', 'bin/dul-receive-pack', 'bin/dul-upload-pack'],
  75. classifiers=[
  76. 'Development Status :: 4 - Beta',
  77. 'License :: OSI Approved :: Apache Software License',
  78. 'Programming Language :: Python :: 2.7',
  79. 'Programming Language :: Python :: 3.4',
  80. 'Programming Language :: Python :: 3.5',
  81. 'Programming Language :: Python :: Implementation :: CPython',
  82. 'Programming Language :: Python :: Implementation :: PyPy',
  83. 'Operating System :: POSIX',
  84. 'Topic :: Software Development :: Version Control',
  85. ],
  86. ext_modules=ext_modules,
  87. test_suite='dulwich.tests.test_suite',
  88. tests_require=tests_require,
  89. distclass=DulwichDistribution,
  90. include_package_data=True,
  91. )