setup.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import re
  5. import sys
  6. import codecs
  7. import setuptools
  8. import setuptools.command.test
  9. from distutils.command.install import INSTALL_SCHEMES
  10. if sys.version_info < (2, 7):
  11. raise Exception('Kombu 4.0 requires Python 2.7 or higher.')
  12. try:
  13. from setuptools import setup
  14. except ImportError:
  15. from distutils.core import setup # noqa
  16. # -- Parse meta
  17. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  18. re_doc = re.compile(r'^"""(.+?)"""')
  19. def add_default(m):
  20. attr_name, attr_value = m.groups()
  21. return ((attr_name, attr_value.strip("\"'")),)
  22. def add_doc(m):
  23. return (('doc', m.groups()[0]),)
  24. pats = {re_meta: add_default, re_doc: add_doc}
  25. here = os.path.abspath(os.path.dirname(__file__))
  26. meta_fh = open(os.path.join(here, 'kombu/__init__.py'))
  27. try:
  28. meta = {}
  29. for line in meta_fh:
  30. if line.strip() == '# -eof meta-':
  31. break
  32. for pattern, handler in pats.items():
  33. m = pattern.match(line.strip())
  34. if m:
  35. meta.update(handler(m))
  36. finally:
  37. meta_fh.close()
  38. # --
  39. def fullsplit(path, result=None):
  40. if result is None:
  41. result = []
  42. head, tail = os.path.split(path)
  43. if head == '':
  44. return [tail] + result
  45. if head == path:
  46. return result
  47. return fullsplit(head, [tail] + result)
  48. for scheme in list(INSTALL_SCHEMES.values()):
  49. scheme['data'] = scheme['purelib']
  50. if os.path.exists('README.rst'):
  51. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  52. else:
  53. long_description = 'See https://pypi.org/project/kombu/'
  54. # -*- Installation Requires -*-
  55. py_version = sys.version_info
  56. is_pypy = hasattr(sys, 'pypy_version_info')
  57. def strip_comments(l):
  58. return l.split('#', 1)[0].strip()
  59. def reqs(*f):
  60. return [
  61. r for r in (
  62. strip_comments(l) for l in open(
  63. os.path.join(os.getcwd(), 'requirements', *f)).readlines()
  64. ) if r]
  65. def extras(*p):
  66. return reqs('extras', *p)
  67. class pytest(setuptools.command.test.test):
  68. user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
  69. def initialize_options(self):
  70. setuptools.command.test.test.initialize_options(self)
  71. self.pytest_args = []
  72. def run_tests(self):
  73. import pytest
  74. sys.exit(pytest.main(self.pytest_args))
  75. setup(
  76. name='kombu',
  77. packages=setuptools.find_packages(exclude=['t', 't.*']),
  78. version=meta['version'],
  79. description=meta['doc'],
  80. long_description=long_description,
  81. keywords='messaging message amqp rabbitmq redis actor producer consumer',
  82. author=meta['author'],
  83. author_email=meta['contact'],
  84. url=meta['homepage'],
  85. platforms=['any'],
  86. zip_safe=False,
  87. license='BSD',
  88. cmdclass={'test': pytest},
  89. python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
  90. install_requires=reqs('default.txt'),
  91. tests_require=reqs('test.txt'),
  92. extras_require={
  93. 'msgpack': extras('msgpack.txt'),
  94. 'yaml': extras('yaml.txt'),
  95. 'redis': extras('redis.txt'),
  96. 'mongodb': extras('mongodb.txt'),
  97. 'sqs': extras('sqs.txt'),
  98. 'zookeeper': extras('zookeeper.txt'),
  99. 'sqlalchemy': extras('sqlalchemy.txt'),
  100. 'librabbitmq': extras('librabbitmq.txt'),
  101. 'pyro': extras('pyro.txt'),
  102. 'slmq': extras('slmq.txt'),
  103. 'azurestoragequeues': extras('azurestoragequeues.txt'),
  104. 'azureservicebus': extras('azureservicebus.txt'),
  105. 'qpid': extras('qpid.txt'),
  106. 'consul': extras('consul.txt'),
  107. },
  108. classifiers=[
  109. 'Development Status :: 5 - Production/Stable',
  110. 'License :: OSI Approved :: BSD License',
  111. 'Operating System :: OS Independent',
  112. 'Programming Language :: Python',
  113. 'Programming Language :: Python :: 3',
  114. 'Programming Language :: Python :: 3.4',
  115. 'Programming Language :: Python :: 3.5',
  116. 'Programming Language :: Python :: 3.6',
  117. 'Programming Language :: Python :: 3.7',
  118. 'Programming Language :: Python :: 2.7',
  119. 'Programming Language :: Python :: 2',
  120. 'Programming Language :: Python :: Implementation :: CPython',
  121. 'Programming Language :: Python :: Implementation :: PyPy',
  122. 'Intended Audience :: Developers',
  123. 'Topic :: Communications',
  124. 'Topic :: System :: Distributed Computing',
  125. 'Topic :: System :: Networking',
  126. 'Topic :: Software Development :: Libraries :: Python Modules',
  127. ],
  128. )