setup.py 5.2 KB

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