forked from celery/celery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
218 lines (177 loc) · 5.95 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import codecs
import platform
extra = {}
tests_require = ["nose", "nose-cover3"]
if sys.version_info >= (3, 0):
extra.update(use_2to3=True)
elif sys.version_info <= (2, 6):
tests_require.append("unittest2")
elif sys.version_info <= (2, 5):
tests_require.append("simplejson")
if sys.version_info < (2, 4):
raise Exception("Celery requires Python 2.4 or higher.")
try:
from setuptools import setup, find_packages, Command
from setuptools.command.test import test
from setuptools.command.install import install
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages, Command
from setuptools.command.test import test
from setuptools.command.install import install
import celery as distmeta
def with_dist_not_in_path(fun):
def _inner(*args, **kwargs):
cwd = os.getcwd()
removed = []
for path in (cwd, cwd + "/", "."):
try:
i = sys.path.index(path)
except ValueError:
pass
else:
removed.append((i, path))
sys.path.remove(path)
try:
dist_module = sys.modules.pop("celery", None)
try:
import celery as existing_module
except ImportError:
pass
else:
kwargs["celery"] = existing_module
return fun(*args, **kwargs)
finally:
for i, path in removed:
sys.path.insert(i, path)
if dist_module:
sys.modules["celery"] = dist_module
return _inner
class Upgrade(object):
old_modules = ("platform", )
def run(self, dist=False):
detect_ = self.detect_existing_installation
if not dist:
detect = with_dist_not_in_path(detect_)
else:
detect = lambda: detect_(distmeta)
path = detect()
if path:
self.remove_modules(path)
def detect_existing_installation(self, celery=None):
path = os.path.dirname(celery.__file__)
sys.stderr.write("* Upgrading old Celery from: \n\t%r\n" % path)
return path
def try_remove(self, file):
try:
os.remove(file)
except OSError:
pass
def remove_modules(self, path):
for module_name in self.old_modules:
sys.stderr.write("* Removing old %s.py...\n" % module_name)
self.try_remove(os.path.join(path, "%s.py" % module_name))
self.try_remove(os.path.join(path, "%s.pyc" % module_name))
class mytest(test):
def run(self, *args, **kwargs):
Upgrade().run(dist=True)
test.run(self, *args, **kwargs)
class quicktest(mytest):
extra_env = dict(SKIP_RLIMITS=1, QUICKTEST=1)
def run(self, *args, **kwargs):
for env_name, env_value in self.extra_env.items():
os.environ[env_name] = str(env_value)
mytest.run(self, *args, **kwargs)
class upgrade(Command):
user_options = []
def run(self, *args, **kwargs):
Upgrade().run()
def initialize_options(self):
pass
def finalize_options(self):
pass
class upgrade_and_install(install):
def run(self, *args, **kwargs):
Upgrade().run()
install.run(self, *args, **kwargs)
install_requires = []
try:
import importlib
except ImportError:
install_requires.append("importlib")
install_requires.extend([
"python-dateutil",
"anyjson",
"kombu>=0.9.1",
"pyparsing",
])
py_version = sys.version_info
if sys.version_info < (2, 6) and not sys.platform.startswith("java"):
install_requires.append("multiprocessing")
if sys.version_info < (2, 5):
install_requires.append("uuid")
if os.path.exists("README.rst"):
long_description = codecs.open("README.rst", "r", "utf-8").read()
else:
long_description = "See http://pypi.python.org/pypi/celery"
console_scripts = [
'celerybeat = celery.bin.celerybeat:main',
'camqadm = celery.bin.camqadm:main',
'celeryev = celery.bin.celeryev:main',
'celeryctl = celery.bin.celeryctl:main',
'celeryd-multi = celery.bin.celeryd_multi:main',
]
import platform
if platform.system() == "Windows":
console_scripts.append('celeryd = celery.bin.celeryd:windows_main')
else:
console_scripts.append('celeryd = celery.bin.celeryd:main')
setup(
name="celery",
version=distmeta.__version__,
description=distmeta.__doc__,
author=distmeta.__author__,
author_email=distmeta.__contact__,
url=distmeta.__homepage__,
platforms=["any"],
license="BSD",
packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
scripts=["bin/celeryd", "bin/celerybeat",
"bin/camqadm", "bin/celeryd-multi",
"bin/celeryev"],
zip_safe=False,
install_requires=install_requires,
tests_require=tests_require,
cmdclass={"install": upgrade_and_install,
"upgrade": upgrade,
"test": mytest,
"quicktest": quicktest},
test_suite="nose.collector",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
"Environment :: No Input/Output (Daemon)",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Topic :: Communications",
"Topic :: System :: Distributed Computing",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
],
entry_points={
'console_scripts': console_scripts,
},
long_description=long_description,
**extra
)