setup.py 5.6 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. if sys.version_info < (2, 6):
  16. raise Exception('Celery 3.1 requires Python 2.6 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 {0!r} package...'.format(task_path))
  30. try:
  31. shutil.rmtree(os.path.abspath(task_path))
  32. except Exception:
  33. sys.stderr.write('Could not remove {0!r}: {1!r}\n'.format(
  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.6
  53. Programming Language :: Python :: 2.7
  54. Programming Language :: Python :: 3
  55. Programming Language :: Python :: 3.2
  56. Programming Language :: Python :: 3.3
  57. Programming Language :: Python :: Implementation :: CPython
  58. Programming Language :: Python :: Implementation :: PyPy
  59. Programming Language :: Python :: Implementation :: Jython
  60. Operating System :: OS Independent
  61. Operating System :: POSIX
  62. Operating System :: Microsoft :: Windows
  63. Operating System :: MacOS :: MacOS X
  64. """
  65. classifiers = [s.strip() for s in classes.split('\n') if s]
  66. # -*- Python 3 -*-
  67. is_py3k = sys.version_info[0] == 3
  68. if is_py3k:
  69. extra.update(use_2to3=True)
  70. # -*- Distribution Meta -*-
  71. import re
  72. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  73. re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)')
  74. re_doc = re.compile(r'^"""(.+?)"""')
  75. rq = lambda s: s.strip("\"'")
  76. def add_default(m):
  77. attr_name, attr_value = m.groups()
  78. return ((attr_name, rq(attr_value)), )
  79. def add_version(m):
  80. v = list(map(rq, m.groups()[0].split(', ')))
  81. return (('VERSION', '.'.join(v[0:3]) + ''.join(v[3:])), )
  82. def add_doc(m):
  83. return (('doc', m.groups()[0]), )
  84. pats = {re_meta: add_default,
  85. re_vers: add_version,
  86. re_doc: add_doc}
  87. here = os.path.abspath(os.path.dirname(__file__))
  88. meta_fh = open(os.path.join(here, 'celery/__init__.py'))
  89. try:
  90. meta = {}
  91. for line in meta_fh:
  92. if line.strip() == '# -eof meta-':
  93. break
  94. for pattern, handler in pats.items():
  95. m = pattern.match(line.strip())
  96. if m:
  97. meta.update(handler(m))
  98. finally:
  99. meta_fh.close()
  100. # -*- Custom Commands -*-
  101. class quicktest(test):
  102. extra_env = dict(SKIP_RLIMITS=1, QUICKTEST=1)
  103. def run(self, *args, **kwargs):
  104. for env_name, env_value in self.extra_env.items():
  105. os.environ[env_name] = str(env_value)
  106. test.run(self, *args, **kwargs)
  107. # -*- Installation Requires -*-
  108. py_version = sys.version_info
  109. is_jython = sys.platform.startswith('java')
  110. is_pypy = hasattr(sys, 'pypy_version_info')
  111. def strip_comments(l):
  112. return l.split('#', 1)[0].strip()
  113. def reqs(f):
  114. return filter(None, [strip_comments(l) for l in open(
  115. os.path.join(os.getcwd(), 'requirements', f)).readlines()])
  116. install_requires = reqs('default-py3k.txt' if is_py3k else 'default.txt')
  117. if is_jython:
  118. install_requires.extend(reqs('jython.txt'))
  119. if py_version[0:2] == (2, 6):
  120. install_requires.extend(reqs('py26.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. # -*- Long Description -*-
  129. if os.path.exists('README.rst'):
  130. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  131. else:
  132. long_description = 'See http://pypi.python.org/pypi/celery'
  133. # -*- Entry Points -*- #
  134. console_scripts = entrypoints['console_scripts'] = [
  135. 'celery = celery.bin.celery:main',
  136. 'celeryd = celery.bin.celeryd:main',
  137. 'celerybeat = celery.bin.celerybeat:main',
  138. 'camqadm = celery.bin.camqadm:main',
  139. 'celeryev = celery.bin.celeryev:main',
  140. 'celeryctl = celery.bin.celeryctl:main',
  141. 'celeryd-multi = celery.bin.celeryd_multi:main',
  142. ]
  143. # bundles: Only relevant for Celery developers.
  144. entrypoints['bundle.bundles'] = ['celery = celery.contrib.bundles:bundles']
  145. # -*- %%% -*-
  146. setup(
  147. name=NAME,
  148. version=meta['VERSION'],
  149. description=meta['doc'],
  150. author=meta['author'],
  151. author_email=meta['contact'],
  152. url=meta['homepage'],
  153. platforms=['any'],
  154. license='BSD',
  155. packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
  156. zip_safe=False,
  157. install_requires=install_requires,
  158. tests_require=tests_require,
  159. test_suite='nose.collector',
  160. cmdclass={'quicktest': quicktest},
  161. classifiers=classifiers,
  162. entry_points=entrypoints,
  163. long_description=long_description,
  164. **extra)