setup.py 5.8 KB

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