forked from ask/celery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pavement.py
207 lines (152 loc) · 4.41 KB
/
pavement.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
import sys
from paver.easy import *
from paver import doctools
from paver.setuputils import setup
PYCOMPILE_CACHES = ["*.pyc", "*$py.class"]
options(
sphinx=Bunch(builddir=".build"),
)
def sphinx_builddir(options):
return path("docs") / options.sphinx.builddir / "html"
@task
def clean_docs(options):
sphinx_builddir(options).rmtree()
@task
@needs("clean_docs", "paver.doctools.html")
def html(options):
destdir = path("Documentation")
destdir.rmtree()
builtdocs = sphinx_builddir(options)
builtdocs.move(destdir)
@task
@needs("paver.doctools.html")
def qhtml(options):
destdir = path("Documentation")
builtdocs = sphinx_builddir(options)
sh("rsync -az %s/ %s" % (builtdocs, destdir))
@task
@needs("clean_docs", "paver.doctools.html")
def ghdocs(options):
builtdocs = sphinx_builddir(options)
sh("git checkout gh-pages && \
cp -r %s/* . && \
git commit . -m 'Rendered documentation for Github Pages.' && \
git push origin gh-pages && \
git checkout master" % builtdocs)
@task
@needs("clean_docs", "paver.doctools.html")
def upload_pypi_docs(options):
builtdocs = path("docs") / options.builddir / "html"
sh("%s setup.py upload_sphinx --upload-dir='%s'" % (
sys.executable, builtdocs))
@task
@needs("upload_pypi_docs", "ghdocs")
def upload_docs(options):
pass
@task
def autodoc(options):
sh("contrib/release/doc4allmods celery")
@task
def verifyindex(options):
sh("contrib/release/verify-reference-index.sh")
@task
def verifyconfigref(options):
sh("PYTHONPATH=. %s contrib/release/verify_config_reference.py \
docs/configuration.rst" % (sys.executable, ))
@task
@cmdopts([
("noerror", "E", "Ignore errors"),
])
def flake8(options):
noerror = getattr(options, "noerror", False)
complexity = getattr(options, "complexity", 22)
sh("""flake8 celery | perl -mstrict -mwarnings -nle'
my $ignore = m/too complex \((\d+)\)/ && $1 le %s;
if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
}{exit $FOUND_FLAKE;
'""" % (complexity, ), ignore_error=noerror)
@task
@cmdopts([
("noerror", "E", "Ignore errors"),
])
def flakeplus(options):
noerror = getattr(options, "noerror", False)
sh("flakeplus celery", ignore_error=noerror)
@task
@cmdopts([
("noerror", "E", "Ignore errors")
])
def flakes(options):
flake8(options)
flakeplus(options)
@task
def clean_readme(options):
path("README").unlink()
path("README.rst").unlink()
@task
@needs("clean_readme")
def readme(options):
sh("%s contrib/release/sphinx-to-rst.py docs/templates/readme.txt \
> README.rst" % (sys.executable, ))
sh("ln -sf README.rst README")
@task
def bump(options):
sh("contrib/release/bump_version.py \
celery/__init__.py docs/includes/introduction.txt \
--before-commit='paver readme'")
@task
@cmdopts([
("coverage", "c", "Enable coverage"),
("quick", "q", "Quick test"),
("verbose", "V", "Make more noise"),
])
def test(options):
cmd = "CELERY_LOADER=default nosetests"
if getattr(options, "coverage", False):
cmd += " --with-coverage3"
if getattr(options, "quick", False):
cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd
if getattr(options, "verbose", False):
cmd += " --verbosity=2"
sh(cmd)
@task
@cmdopts([
("noerror", "E", "Ignore errors"),
])
def pep8(options):
noerror = getattr(options, "noerror", False)
return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
@task
def removepyc(options):
sh("find . -type f -a \\( %s \\) | xargs rm" % (
" -o ".join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
@task
@needs("removepyc")
def gitclean(options):
sh("git clean -xdn")
@task
@needs("removepyc")
def gitcleanforce(options):
sh("git clean -xdf")
@task
@needs("flakes", "autodoc", "verifyindex",
"verifyconfigref", "test", "gitclean")
def releaseok(options):
pass
@task
@needs("releaseok", "removepyc", "upload_docs")
def release(options):
pass
@task
def verify_authors(options):
sh("git shortlog -se | cut -f2 | contrib/release/attribution.py")
@task
def coreloc(options):
sh("xargs sloccount < contrib/release/core-modules.txt")
@task
def testloc(options):
sh("sloccount celery/tests")
@task
def loc(options):
sh("sloccount celery")