setup.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. try:
  10. import platform
  11. _pyimp = platform.python_implementation
  12. except (AttributeError, ImportError):
  13. def _pyimp():
  14. return 'Python'
  15. NAME = 'django-celery-beat'
  16. PACKAGE = 'django_celery_beat'
  17. E_UNSUPPORTED_PYTHON = '%s 1.0 requires %%s %%s or later!' % (NAME,)
  18. PYIMP = _pyimp()
  19. PY26_OR_LESS = sys.version_info < (2, 7)
  20. PY3 = sys.version_info[0] == 3
  21. PY33_OR_LESS = PY3 and sys.version_info < (3, 4)
  22. PYPY_VERSION = getattr(sys, 'pypy_version_info', None)
  23. PYPY = PYPY_VERSION is not None
  24. PYPY24_ATLEAST = PYPY_VERSION and PYPY_VERSION >= (2, 4)
  25. if PY26_OR_LESS:
  26. raise Exception(E_UNSUPPORTED_PYTHON % (PYIMP, '2.7'))
  27. elif PY33_OR_LESS and not PYPY24_ATLEAST:
  28. raise Exception(E_UNSUPPORTED_PYTHON % (PYIMP, '3.4'))
  29. # -*- Classifiers -*-
  30. classes = """
  31. Development Status :: 5 - Production/Stable
  32. License :: OSI Approved :: BSD License
  33. Programming Language :: Python
  34. Programming Language :: Python :: 2
  35. Programming Language :: Python :: 2.7
  36. Programming Language :: Python :: 3
  37. Programming Language :: Python :: 3.4
  38. Programming Language :: Python :: 3.5
  39. Programming Language :: Python :: Implementation :: CPython
  40. Programming Language :: Python :: Implementation :: PyPy
  41. Framework :: Django
  42. Framework :: Django :: 1.8
  43. Framework :: Django :: 1.9
  44. Framework :: Django :: 1.10
  45. Framework :: Django :: 1.11
  46. Framework :: Django :: 2.0
  47. Operating System :: OS Independent
  48. Topic :: Communications
  49. Topic :: System :: Distributed Computing
  50. Topic :: Software Development :: Libraries :: Python Modules
  51. """
  52. classifiers = [s.strip() for s in classes.split('\n') if s]
  53. # -*- Distribution Meta -*-
  54. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  55. re_doc = re.compile(r'^"""(.+?)"""')
  56. def add_default(m):
  57. attr_name, attr_value = m.groups()
  58. return ((attr_name, attr_value.strip("\"'")),)
  59. def add_doc(m):
  60. return (('doc', m.groups()[0]),)
  61. pats = {re_meta: add_default,
  62. re_doc: add_doc}
  63. here = os.path.abspath(os.path.dirname(__file__))
  64. with open(os.path.join(here, PACKAGE, '__init__.py')) as meta_fh:
  65. meta = {}
  66. for line in meta_fh:
  67. if line.strip() == '# -eof meta-':
  68. break
  69. for pattern, handler in pats.items():
  70. m = pattern.match(line.strip())
  71. if m:
  72. meta.update(handler(m))
  73. # -*- Installation Requires -*-
  74. def strip_comments(l):
  75. return l.split('#', 1)[0].strip()
  76. def _pip_requirement(req):
  77. if req.startswith('-r '):
  78. _, path = req.split()
  79. return reqs(*path.split('/'))
  80. return [req]
  81. def _reqs(*f):
  82. return [
  83. _pip_requirement(r) for r in (
  84. strip_comments(l) for l in open(
  85. os.path.join(os.getcwd(), 'requirements', *f)).readlines()
  86. ) if r]
  87. def reqs(*f):
  88. return [req for subreq in _reqs(*f) for req in subreq]
  89. # -*- Long Description -*-
  90. if os.path.exists('README.rst'):
  91. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  92. else:
  93. long_description = 'See http://pypi.python.org/pypi/%s' % (NAME,)
  94. # -*- %%% -*-
  95. class pytest(setuptools.command.test.test):
  96. user_options = [('pytest-args=', 'a', 'Arguments to pass to py.test')]
  97. def initialize_options(self):
  98. setuptools.command.test.test.initialize_options(self)
  99. self.pytest_args = []
  100. def run_tests(self):
  101. import pytest
  102. sys.exit(pytest.main(self.pytest_args))
  103. setuptools.setup(
  104. name=NAME,
  105. packages=setuptools.find_packages(exclude=[
  106. 'ez_setup', 't', 't.*',
  107. ]),
  108. version=meta['version'],
  109. description=meta['doc'],
  110. long_description=long_description,
  111. keywords='django celery beat periodic task database',
  112. author=meta['author'],
  113. author_email=meta['contact'],
  114. url=meta['homepage'],
  115. platforms=['any'],
  116. license='BSD',
  117. install_requires=reqs('default.txt'),
  118. tests_require=reqs('test.txt') + reqs('test-django.txt'),
  119. cmdclass={'test': pytest},
  120. classifiers=classifiers,
  121. entry_points={
  122. 'celery.beat_schedulers': [
  123. 'django = django_celery_beat.schedulers:DatabaseScheduler',
  124. ],
  125. },
  126. include_package_data=False,
  127. zip_safe=False,
  128. )