setup.py 5.4 KB

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