setup.py 3.8 KB

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