setup.py 5.0 KB

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