setup.py 5.6 KB

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