setup.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import sys
  5. import codecs
  6. import platform
  7. if sys.version_info < (2, 5):
  8. raise Exception('Celery requires Python 2.5 or higher.')
  9. try:
  10. orig_path = sys.path[:]
  11. for path in (os.path.curdir, os.getcwd()):
  12. if path in sys.path:
  13. sys.path.remove(path)
  14. try:
  15. import celery.app
  16. import imp
  17. import shutil
  18. _, task_path, _ = imp.find_module('task', celery.app.__path__)
  19. if task_path.endswith('/task'):
  20. print('- force upgrading previous installation')
  21. print(' - removing %r package...' % task_path)
  22. try:
  23. shutil.rmtree(os.path.abspath(task_path))
  24. except Exception:
  25. sys.stderr.write('Could not remove %r: %r\n' % (
  26. task_path, sys.exc_info[1]))
  27. except ImportError:
  28. print('Upgrade: no old version found.')
  29. finally:
  30. sys.path[:] = orig_path
  31. except ImportError:
  32. pass
  33. try:
  34. from setuptools import setup, find_packages
  35. from setuptools.command.test import test
  36. except ImportError:
  37. raise
  38. from ez_setup import use_setuptools
  39. use_setuptools()
  40. from setuptools import setup, find_packages # noqa
  41. from setuptools.command.test import test # noqa
  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 :: Implementation :: CPython
  57. Programming Language :: Python :: Implementation :: PyPy
  58. Programming Language :: Python :: Implementation :: Jython
  59. Operating System :: OS Independent
  60. Operating System :: POSIX
  61. Operating System :: Microsoft :: Windows
  62. Operating System :: MacOS :: MacOS X
  63. """
  64. classifiers = [s.strip() for s in classes.split('\n') if s]
  65. # -*- Python 3 -*-
  66. is_py3k = sys.version_info >= (3, 0)
  67. if is_py3k:
  68. extra.update(use_2to3=True)
  69. # -*- Distribution Meta -*-
  70. import re
  71. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  72. re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)')
  73. re_doc = re.compile(r'^"""(.+?)"""')
  74. rq = lambda s: s.strip("\"'")
  75. def add_default(m):
  76. attr_name, attr_value = m.groups()
  77. return ((attr_name, rq(attr_value)), )
  78. def add_version(m):
  79. v = list(map(rq, m.groups()[0].split(', ')))
  80. return (('VERSION', '.'.join(v[0:3]) + ''.join(v[3:])), )
  81. def add_doc(m):
  82. return (('doc', m.groups()[0]), )
  83. pats = {re_meta: add_default,
  84. re_vers: add_version,
  85. re_doc: add_doc}
  86. here = os.path.abspath(os.path.dirname(__file__))
  87. meta_fh = open(os.path.join(here, 'celery/__init__.py'))
  88. try:
  89. meta = {}
  90. for line in meta_fh:
  91. if line.strip() == '# -eof meta-':
  92. break
  93. for pattern, handler in pats.items():
  94. m = pattern.match(line.strip())
  95. if m:
  96. meta.update(handler(m))
  97. finally:
  98. meta_fh.close()
  99. # -*- Custom Commands -*-
  100. class quicktest(test):
  101. extra_env = dict(SKIP_RLIMITS=1, QUICKTEST=1)
  102. def run(self, *args, **kwargs):
  103. for env_name, env_value in self.extra_env.items():
  104. os.environ[env_name] = str(env_value)
  105. test.run(self, *args, **kwargs)
  106. # -*- Installation Dependencies -*-
  107. py_version = sys.version_info
  108. is_jython = sys.platform.startswith('java')
  109. is_pypy = hasattr(sys, 'pypy_version_info')
  110. def reqs(f):
  111. return filter(None, [l.strip() for l in open(
  112. os.path.join(os.getcwd(), 'requirements', f)).readlines()])
  113. install_requires = reqs('default-py3k.txt' if is_py3k else 'default.txt')
  114. if is_jython:
  115. install_requires.extend(reqs('jython.txt'))
  116. if py_version[0:2] == (2, 6):
  117. install_requires.extend(reqs('py26.txt'))
  118. elif py_version[0:2] == (2, 5):
  119. install_requires.extend(reqs('py25.txt'))
  120. # -*- Tests Requires -*-
  121. tests_require = ['nose', 'nose-cover3', 'sqlalchemy', 'mock==dev']
  122. if sys.version_info < (2, 7):
  123. tests_require.append('unittest2')
  124. elif sys.version_info <= (2, 5):
  125. tests_require.append('simplejson')
  126. # -*- Long Description -*-
  127. if os.path.exists('README.rst'):
  128. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  129. else:
  130. long_description = 'See http://pypi.python.org/pypi/celery'
  131. # -*- Entry Points -*- #
  132. console_scripts = entrypoints['console_scripts'] = [
  133. 'celery = celery.bin.celery:main',
  134. 'celeryd = celery.bin.celeryd:main',
  135. 'celerybeat = celery.bin.celerybeat:main',
  136. 'camqadm = celery.bin.camqadm:main',
  137. 'celeryev = celery.bin.celeryev:main',
  138. 'celeryctl = celery.bin.celeryctl:main',
  139. 'celeryd-multi = celery.bin.celeryd_multi:main',
  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)