setup.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import sys
  5. import codecs
  6. import platform
  7. extra = {}
  8. tests_require = ["nose", "nose-cover3", "sqlalchemy", "mock"]
  9. is_py3k = sys.version_info >= (3, 0)
  10. if is_py3k:
  11. extra.update(use_2to3=True)
  12. elif sys.version_info < (2, 7):
  13. tests_require.append("unittest2")
  14. elif sys.version_info <= (2, 5):
  15. tests_require.append("simplejson")
  16. if sys.version_info < (2, 5):
  17. raise Exception("Celery requires Python 2.5 or higher.")
  18. try:
  19. from setuptools import setup, find_packages
  20. from setuptools.command.test import test
  21. except ImportError:
  22. raise
  23. from ez_setup import use_setuptools
  24. use_setuptools()
  25. from setuptools import setup, find_packages # noqa
  26. from setuptools.command.test import test # noqa
  27. # -- Parse meta
  28. import re
  29. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  30. re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)')
  31. re_doc = re.compile(r'^"""(.+?)"""')
  32. rq = lambda s: s.strip("\"'")
  33. def add_default(m):
  34. attr_name, attr_value = m.groups()
  35. return ((attr_name, rq(attr_value)), )
  36. def add_version(m):
  37. v = list(map(rq, m.groups()[0].split(", ")))
  38. return (("VERSION", ".".join(v[0:3]) + "".join(v[3:])), )
  39. def add_doc(m):
  40. return (("doc", m.groups()[0]), )
  41. pats = {re_meta: add_default,
  42. re_vers: add_version,
  43. re_doc: add_doc}
  44. here = os.path.abspath(os.path.dirname(__file__))
  45. meta_fh = open(os.path.join(here, "celery/__init__.py"))
  46. try:
  47. meta = {}
  48. for line in meta_fh:
  49. if line.strip() == '# -eof meta-':
  50. break
  51. for pattern, handler in pats.items():
  52. m = pattern.match(line.strip())
  53. if m:
  54. meta.update(handler(m))
  55. finally:
  56. meta_fh.close()
  57. # --
  58. class quicktest(test):
  59. extra_env = dict(SKIP_RLIMITS=1, QUICKTEST=1)
  60. def run(self, *args, **kwargs):
  61. for env_name, env_value in self.extra_env.items():
  62. os.environ[env_name] = str(env_value)
  63. test.run(self, *args, **kwargs)
  64. install_requires = []
  65. try:
  66. import importlib # noqa
  67. except ImportError:
  68. install_requires.append("importlib")
  69. install_requires.extend([
  70. "anyjson>=0.3.1",
  71. "kombu>=1.4.3,<3.0.0",
  72. ])
  73. if is_py3k:
  74. install_requires.append("python-dateutil>=2.0.0")
  75. else:
  76. install_requires.append("python-dateutil>=1.5.0,<2.0.0")
  77. py_version = sys.version_info
  78. is_jython = sys.platform.startswith("java")
  79. is_pypy = hasattr(sys, "pypy_version_info")
  80. if sys.version_info < (2, 7):
  81. install_requires.append("ordereddict") # Replacement for the ordered dict
  82. if sys.version_info < (2, 6) and not (is_jython or is_pypy):
  83. install_requires.append("multiprocessing")
  84. if is_jython:
  85. install_requires.append("threadpool")
  86. install_requires.append("simplejson")
  87. if os.path.exists("README.rst"):
  88. long_description = codecs.open("README.rst", "r", "utf-8").read()
  89. else:
  90. long_description = "See http://pypi.python.org/pypi/celery"
  91. console_scripts = [
  92. 'celerybeat = celery.bin.celerybeat:main',
  93. 'camqadm = celery.bin.camqadm:main',
  94. 'celeryev = celery.bin.celeryev:main',
  95. 'celeryctl = celery.bin.celeryctl:main',
  96. 'celeryd-multi = celery.bin.celeryd_multi:main',
  97. ]
  98. if platform.system() == "Windows":
  99. console_scripts.append('celeryd = celery.bin.celeryd:windows_main')
  100. else:
  101. console_scripts.append('celeryd = celery.bin.celeryd:main')
  102. setup(
  103. name="celery",
  104. version=meta["VERSION"],
  105. description=meta["doc"],
  106. author=meta["author"],
  107. author_email=meta["contact"],
  108. url=meta["homepage"],
  109. platforms=["any"],
  110. license="BSD",
  111. packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
  112. zip_safe=False,
  113. install_requires=install_requires,
  114. tests_require=tests_require,
  115. cmdclass={"test": test,
  116. "quicktest": quicktest},
  117. test_suite="nose.collector",
  118. classifiers=[
  119. "Development Status :: 5 - Production/Stable",
  120. "Operating System :: OS Independent",
  121. "Environment :: No Input/Output (Daemon)",
  122. "Intended Audience :: Developers",
  123. "License :: OSI Approved :: BSD License",
  124. "Operating System :: POSIX",
  125. "Topic :: Communications",
  126. "Topic :: System :: Distributed Computing",
  127. "Topic :: Software Development :: Libraries :: Python Modules",
  128. "Programming Language :: Python",
  129. "Programming Language :: Python :: 2",
  130. "Programming Language :: Python :: 2.5",
  131. "Programming Language :: Python :: 2.6",
  132. "Programming Language :: Python :: 2.7",
  133. "Programming Language :: Python :: 3",
  134. ],
  135. entry_points={
  136. 'console_scripts': console_scripts,
  137. },
  138. long_description=long_description,
  139. **extra)