Skip to content
Newer
Older
100644 188 lines (136 sloc) 3.83 KB
8d66ae1 @ask Upgrade distribution tools
authored
1 import os
2 import sys
3
4 from paver.easy import *
5 from paver import doctools
6 from paver.setuputils import setup
7
8 PYCOMPILE_CACHES = ["*.pyc", "*$py.class"]
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
9
10 options(
11 sphinx=Bunch(builddir=".build"),
12 )
13
8ab9dbb PEP8ify
Ask Solem authored
14
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
15 def sphinx_builddir(options):
16 return path("docs") / options.sphinx.builddir / "html"
17
18
19 @task
20 def clean_docs(options):
21 sphinx_builddir(options).rmtree()
22
23
24 @task
25 @needs("clean_docs", "paver.doctools.html")
26 def html(options):
27 destdir = path("Documentation")
28 destdir.rmtree()
29 builtdocs = sphinx_builddir(options)
30 builtdocs.move(destdir)
31
32
33 @task
6e91036 Added Sphinx documentation and distro utils
Ask Solem authored
34 @needs("paver.doctools.html")
35 def qhtml(options):
36 destdir = path("Documentation")
37 builtdocs = sphinx_builddir(options)
38 sh("rsync -az %s/ %s" % (builtdocs, destdir))
39
40
41 @task
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
42 @needs("clean_docs", "paver.doctools.html")
43 def ghdocs(options):
44 builtdocs = sphinx_builddir(options)
45 sh("git checkout gh-pages && \
46 cp -r %s/* . && \
47 git commit . -m 'Rendered documentation for Github Pages.' && \
48 git push origin gh-pages && \
49 git checkout master" % builtdocs)
50
51
52 @task
53 @needs("clean_docs", "paver.doctools.html")
54 def upload_pypi_docs(options):
55 builtdocs = path("docs") / options.builddir / "html"
8d66ae1 @ask Upgrade distribution tools
authored
56 sh("%s setup.py upload_sphinx --upload-dir='%s'" % (
57 sys.executable, builtdocs))
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
58
59
60 @task
61 @needs("upload_pypi_docs", "ghdocs")
62 def upload_docs(options):
63 pass
64
65
66 @task
67 def autodoc(options):
68 sh("contrib/release/doc4allmods djcelery")
69
70
71 @task
72 def verifyindex(options):
73 sh("contrib/release/verify-reference-index.sh")
74
75
76 @task
8d66ae1 @ask Upgrade distribution tools
authored
77 @cmdopts([
78 ("noerror", "E", "Ignore errors"),
79 ])
80 def flake8(options):
81 noerror = getattr(options, "noerror", False)
82 complexity = getattr(options, "complexity", 22)
83 migrations_path = os.path.join("djcelery", "migrations", "0.+?\.py")
84 sh("""flake8 djcelery | perl -mstrict -mwarnings -nle'
85 my $ignore = (m/too complex \((\d+)\)/ && $1 le %s)
86 || (m{^%s});
87 if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
88 }{exit $FOUND_FLAKE;
89 '""" % (complexity, migrations_path), ignore_error=noerror)
90
91
92 @task
93 @cmdopts([
94 ("noerror", "E", "Ignore errors"),
95 ])
96 def flakeplus(options):
97 noerror = getattr(options, "noerror", False)
98 sh("python contrib/release/flakeplus.py djcelery",
99 ignore_error=noerror)
100
101
102 @task
103 @cmdopts([
104 ("noerror", "E", "Ignore errors")
105 ])
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
106 def flakes(options):
8d66ae1 @ask Upgrade distribution tools
authored
107 flake8(options)
108 flakeplus(options)
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
109
110
111 @task
112 def clean_readme(options):
113 path("README").unlink()
114 path("README.rst").unlink()
115
116
117 @task
118 @needs("clean_readme")
119 def readme(options):
8d66ae1 @ask Upgrade distribution tools
authored
120 sh("%s contrib/release/sphinx-to-rst.py docs/introduction.rst \
121 > README.rst" % (sys.executable, ))
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
122 sh("ln -sf README.rst README")
123
124
125 @task
126 def bump(options):
127 sh("bump -c djcelery")
128
129
130 @task
131 @cmdopts([
132 ("coverage", "c", "Enable coverage"),
133 ("quick", "q", "Quick test"),
134 ("verbose", "V", "Make more noise"),
135 ])
136 def test(options):
8d66ae1 @ask Upgrade distribution tools
authored
137 sh("%s setup.py test" % (sys.executable, ))
747b493 @ask Use flake8 instead of pep8+pyflakes, and adds it as a step to release…
authored
138
139
140 @task
141 @cmdopts([
142 ("noerror", "E", "Ignore errors"),
143 ])
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
144 def pep8(options):
145 noerror = getattr(options, "noerror", False)
146 return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
147 print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
148
149
150 @task
151 def removepyc(options):
8d66ae1 @ask Upgrade distribution tools
authored
152 sh("find . -type f -a \\( %s \\) | xargs rm" % (
153 " -o ".join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
154
155
156 @task
157 @needs("removepyc")
158 def gitclean(options):
159 sh("git clean -xdn")
160
161
162 @task
163 @needs("removepyc")
164 def gitcleanforce(options):
165 sh("git clean -xdf")
166
167
168 @task
8d66ae1 @ask Upgrade distribution tools
authored
169 @needs("flakes", "autodoc", "verifyindex", "test", "gitclean")
76b416b Added standard distribution files and a first draft for a README
Ask Solem authored
170 def releaseok(options):
171 pass
172
173
174 @task
175 @needs("releaseok", "removepyc", "upload_docs")
176 def release(options):
177 pass
8d66ae1 @ask Upgrade distribution tools
authored
178
179
180 @task
181 def testloc(options):
182 sh("sloccount djcelery/tests")
183
184
185 @task
186 def loc(options):
187 sh("sloccount djcelery")
Something went wrong with that request. Please try again.