setup.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. try:
  4. from setuptools import setup, find_packages
  5. from setuptools.command.test import test
  6. except ImportError:
  7. raise
  8. from ez_setup import use_setuptools
  9. use_setuptools()
  10. from setuptools import setup, find_packages # noqa
  11. from setuptools.command.test import test # noqa
  12. import os
  13. import sys
  14. import codecs
  15. CELERY_COMPAT_PROGRAMS = int(os.environ.get('CELERY_COMPAT_PROGRAMS', 1))
  16. if sys.version_info < (2, 5):
  17. raise Exception('Celery requires Python 2.5 or higher.')
  18. try:
  19. orig_path = sys.path[:]
  20. for path in (os.path.curdir, os.getcwd()):
  21. if path in sys.path:
  22. sys.path.remove(path)
  23. try:
  24. import celery.app
  25. import imp
  26. import shutil
  27. _, task_path, _ = imp.find_module('task', celery.app.__path__)
  28. if task_path.endswith('/task'):
  29. print('- force upgrading previous installation')
  30. print(' - removing %r package...' % task_path)
  31. try:
  32. shutil.rmtree(os.path.abspath(task_path))
  33. except Exception:
  34. sys.stderr.write('Could not remove %r: %r\n' % (
  35. task_path, sys.exc_info[1]))
  36. except ImportError:
  37. print('Upgrade: no old version found.')
  38. finally:
  39. sys.path[:] = orig_path
  40. except:
  41. pass
  42. NAME = 'celery'
  43. entrypoints = {}
  44. extra = {}
  45. # -*- Classifiers -*-
  46. classes = """
  47. Development Status :: 5 - Production/Stable
  48. License :: OSI Approved :: BSD License
  49. Topic :: System :: Distributed Computing
  50. Topic :: Software Development :: Object Brokering
  51. Programming Language :: Python
  52. Programming Language :: Python :: 2
  53. Programming Language :: Python :: 2.5
  54. Programming Language :: Python :: 2.6
  55. Programming Language :: Python :: 2.7
  56. Programming Language :: Python :: 3
  57. Programming Language :: Python :: 3.2
  58. Programming Language :: Python :: 3.3
  59. Programming Language :: Python :: Implementation :: CPython
  60. Programming Language :: Python :: Implementation :: PyPy
  61. Programming Language :: Python :: Implementation :: Jython
  62. Operating System :: OS Independent
  63. Operating System :: POSIX
  64. Operating System :: Microsoft :: Windows
  65. Operating System :: MacOS :: MacOS X
  66. """
  67. classifiers = [s.strip() for s in classes.split('\n') if s]
  68. # -*- Python 3 -*-
  69. is_py3k = sys.version_info[0] == 3
  70. if is_py3k:
  71. extra.update(use_2to3=True)
  72. # -*- Distribution Meta -*-
  73. import re
  74. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  75. re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)')
  76. re_doc = re.compile(r'^"""(.+?)"""')
  77. rq = lambda s: s.strip("\"'")
  78. def add_default(m):
  79. attr_name, attr_value = m.groups()
  80. return ((attr_name, rq(attr_value)), )
  81. def add_version(m):
  82. v = list(map(rq, m.groups()[0].split(', ')))
  83. return (('VERSION', '.'.join(v[0:3]) + ''.join(v[3:])), )
  84. def add_doc(m):
  85. return (('doc', m.groups()[0]), )
  86. pats = {re_meta: add_default,
  87. re_vers: add_version,
  88. re_doc: add_doc}
  89. here = os.path.abspath(os.path.dirname(__file__))
  90. meta_fh = open(os.path.join(here, 'celery/__init__.py'))
  91. try:
  92. meta = {}
  93. for line in meta_fh:
  94. if line.strip() == '# -eof meta-':
  95. break
  96. for pattern, handler in pats.items():
  97. m = pattern.match(line.strip())
  98. if m:
  99. meta.update(handler(m))
  100. finally:
  101. meta_fh.close()
  102. # -*- Custom Commands -*-
  103. class quicktest(test):
  104. extra_env = dict(SKIP_RLIMITS=1, QUICKTEST=1)
  105. def run(self, *args, **kwargs):
  106. for env_name, env_value in self.extra_env.items():
  107. os.environ[env_name] = str(env_value)
  108. test.run(self, *args, **kwargs)
  109. # -*- Installation Requires -*-
  110. py_version = sys.version_info
  111. is_jython = sys.platform.startswith('java')
  112. is_pypy = hasattr(sys, 'pypy_version_info')
  113. def strip_comments(l):
  114. return l.split('#', 1)[0].strip()
  115. def reqs(f):
  116. return filter(None, [strip_comments(l) for l in open(
  117. os.path.join(os.getcwd(), 'requirements', f)).readlines()])
  118. install_requires = reqs('default-py3k.txt' if is_py3k else 'default.txt')
  119. if is_jython:
  120. install_requires.extend(reqs('jython.txt'))
  121. # -*- Tests Requires -*-
  122. tests_require = reqs('test.txt')
  123. # -*- Long Description -*-
  124. if os.path.exists('README.rst'):
  125. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  126. else:
  127. long_description = 'See http://pypi.python.org/pypi/celery'
  128. # -*- Entry Points -*- #
  129. console_scripts = entrypoints['console_scripts'] = [
  130. 'celery = celery.__main__:main',
  131. ]
  132. if CELERY_COMPAT_PROGRAMS:
  133. console_scripts.extend([
  134. 'celeryd = celery.__main__:_compat_worker',
  135. 'celerybeat = celery.__main__:_compat_beat',
  136. 'camqadm = celery.bin.camqadm:main',
  137. 'celeryev = celery.bin.celeryev:main',
  138. 'celeryctl = celery.bin.celeryctl:main',
  139. 'celeryd-multi = celery.__main__:_compat_multi',
  140. ])
  141. # bundles: Only relevant for Celery developers.
  142. entrypoints['bundle.bundles'] = ['celery = celery.contrib.bundles:bundles']
  143. # -*- %%% -*-
  144. setup(
  145. name=NAME,
  146. version=meta['VERSION'],
  147. description=meta['doc'],
  148. author=meta['author'],
  149. author_email=meta['contact'],
  150. url=meta['homepage'],
  151. platforms=['any'],
  152. license='BSD',
  153. packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
  154. zip_safe=False,
  155. install_requires=install_requires,
  156. tests_require=tests_require,
  157. test_suite='nose.collector',
  158. cmdclass={'quicktest': quicktest},
  159. classifiers=classifiers,
  160. entry_points=entrypoints,
  161. long_description=long_description,
  162. **extra)