setup.py 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. try:
  4. from setuptools import setup, find_packages
  5. from setuptools.command.test import test
  6. is_setuptools = True
  7. except ImportError:
  8. raise
  9. from ez_setup import use_setuptools
  10. use_setuptools()
  11. from setuptools import setup, find_packages # noqa
  12. from setuptools.command.test import test # noqa
  13. is_setuptools = False
  14. import os
  15. import sys
  16. import codecs
  17. CELERY_COMPAT_PROGRAMS = int(os.environ.get('CELERY_COMPAT_PROGRAMS', 1))
  18. if sys.version_info < (2, 6):
  19. raise Exception('Celery 3.1 requires Python 2.6 or higher.')
  20. downgrade_packages = [
  21. 'celery.app.task',
  22. ]
  23. orig_path = sys.path[:]
  24. for path in (os.path.curdir, os.getcwd()):
  25. if path in sys.path:
  26. sys.path.remove(path)
  27. try:
  28. import imp
  29. import shutil
  30. for pkg in downgrade_packages:
  31. try:
  32. parent, module = pkg.rsplit('.', 1)
  33. print('- Trying to upgrade %r in %r' % (module, parent))
  34. parent_mod = __import__(parent, None, None, [parent])
  35. _, mod_path, _ = imp.find_module(module, parent_mod.__path__)
  36. if mod_path.endswith('/' + module):
  37. print('- force upgrading previous installation')
  38. print(' - removing {0!r} package...'.format(mod_path))
  39. try:
  40. shutil.rmtree(os.path.abspath(mod_path))
  41. except Exception:
  42. sys.stderr.write('Could not remove {0!r}: {1!r}\n'.format(
  43. mod_path, sys.exc_info[1]))
  44. except ImportError:
  45. print('- upgrade %s: no old version found.' % module)
  46. except:
  47. pass
  48. finally:
  49. sys.path[:] = orig_path
  50. NAME = 'celery'
  51. entrypoints = {}
  52. extra = {}
  53. # -*- Classifiers -*-
  54. classes = """
  55. Development Status :: 5 - Production/Stable
  56. License :: OSI Approved :: BSD License
  57. Topic :: System :: Distributed Computing
  58. Topic :: Software Development :: Object Brokering
  59. Programming Language :: Python
  60. Programming Language :: Python :: 2
  61. Programming Language :: Python :: 2.6
  62. Programming Language :: Python :: 2.7
  63. Programming Language :: Python :: 3
  64. Programming Language :: Python :: 3.3
  65. Programming Language :: Python :: 3.4
  66. Programming Language :: Python :: Implementation :: CPython
  67. Programming Language :: Python :: Implementation :: PyPy
  68. Programming Language :: Python :: Implementation :: Jython
  69. Operating System :: OS Independent
  70. Operating System :: POSIX
  71. Operating System :: Microsoft :: Windows
  72. Operating System :: MacOS :: MacOS X
  73. """
  74. classifiers = [s.strip() for s in classes.split('\n') if s]
  75. PY3 = sys.version_info[0] == 3
  76. JYTHON = sys.platform.startswith('java')
  77. PYPY = hasattr(sys, 'pypy_version_info')
  78. # -*- Distribution Meta -*-
  79. import re
  80. re_meta = re.compile(r'__(\w+?)__\s*=\s*(.*)')
  81. re_vers = re.compile(r'VERSION\s*=\s*\((.*?)\)')
  82. re_doc = re.compile(r'^"""(.+?)"""')
  83. rq = lambda s: s.strip("\"'")
  84. def add_default(m):
  85. attr_name, attr_value = m.groups()
  86. return ((attr_name, rq(attr_value)), )
  87. def add_version(m):
  88. v = list(map(rq, m.groups()[0].split(', ')))
  89. return (('VERSION', '.'.join(v[0:3]) + ''.join(v[3:])), )
  90. def add_doc(m):
  91. return (('doc', m.groups()[0]), )
  92. pats = {re_meta: add_default,
  93. re_vers: add_version,
  94. re_doc: add_doc}
  95. here = os.path.abspath(os.path.dirname(__file__))
  96. meta_fh = open(os.path.join(here, 'celery/__init__.py'))
  97. try:
  98. meta = {}
  99. for line in meta_fh:
  100. if line.strip() == '# -eof meta-':
  101. break
  102. for pattern, handler in pats.items():
  103. m = pattern.match(line.strip())
  104. if m:
  105. meta.update(handler(m))
  106. finally:
  107. meta_fh.close()
  108. # -*- Installation Requires -*-
  109. py_version = sys.version_info
  110. def strip_comments(l):
  111. return l.split('#', 1)[0].strip()
  112. def reqs(*f):
  113. return [
  114. r for r in (
  115. strip_comments(l) for l in open(
  116. os.path.join(os.getcwd(), 'requirements', *f)).readlines()
  117. ) if r]
  118. install_requires = reqs('default.txt')
  119. if JYTHON:
  120. install_requires.extend(reqs('jython.txt'))
  121. # -*- Tests Requires -*-
  122. tests_require = reqs('test3.txt' if PY3 else 'test.txt')
  123. # -*- Long Description -*-
  124. if os.path.exists('README.rst'):
  125. long_description = codecs.open('README.rst', 'r', 'utf-8').read()
  126. else:
  127. long_description = 'See http://pypi.python.org/pypi/celery'
  128. # -*- Entry Points -*- #
  129. console_scripts = entrypoints['console_scripts'] = [
  130. 'celery = celery.__main__:main',
  131. ]
  132. if CELERY_COMPAT_PROGRAMS:
  133. console_scripts.extend([
  134. 'celeryd = celery.__main__:_compat_worker',
  135. 'celerybeat = celery.__main__:_compat_beat',
  136. 'celeryd-multi = celery.__main__:_compat_multi',
  137. ])
  138. if is_setuptools:
  139. extras = lambda *p: reqs('extras', *p)
  140. extra['extras_require'] = {
  141. # Celery specific
  142. 'auth': extras('auth.txt'),
  143. 'cassandra': extras('cassandra.txt'),
  144. 'memcache': extras('memcache.txt'),
  145. 'couchbase': extras('couchbase.txt'),
  146. 'threads': extras('threads.txt'),
  147. 'eventlet': extras('eventlet.txt'),
  148. 'gevent': extras('gevent.txt'),
  149. 'msgpack': extras('msgpack.txt'),
  150. 'yaml': extras('yaml.txt'),
  151. 'redis': extras('redis.txt'),
  152. 'mongodb': extras('mongodb.txt'),
  153. 'sqs': extras('sqs.txt'),
  154. 'couchdb': extras('couchdb.txt'),
  155. 'beanstalk': extras('beanstalk.txt'),
  156. 'zookeeper': extras('zookeeper.txt'),
  157. 'zeromq': extras('zeromq.txt'),
  158. 'sqlalchemy': extras('sqlalchemy.txt'),
  159. 'librabbitmq': extras('librabbitmq.txt'),
  160. 'pyro': extras('pyro.txt'),
  161. 'slmq': extras('slmq.txt'),
  162. }
  163. # -*- %%% -*-
  164. setup(
  165. name=NAME,
  166. version=meta['VERSION'],
  167. description=meta['doc'],
  168. author=meta['author'],
  169. author_email=meta['contact'],
  170. url=meta['homepage'],
  171. platforms=['any'],
  172. license='BSD',
  173. packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
  174. zip_safe=False,
  175. install_requires=install_requires,
  176. tests_require=tests_require,
  177. test_suite='nose.collector',
  178. classifiers=classifiers,
  179. entry_points=entrypoints,
  180. long_description=long_description,
  181. **extra)