setup.py 5.5 KB

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