kombu/pavement.py

191 lines
4.2 KiB
Python
Raw Normal View History

import os
from paver.easy import * # noqa
from paver import doctools # noqa
from paver.setuputils import setup # noqa
2010-07-22 14:14:03 +00:00
2012-11-08 20:20:41 +00:00
PYCOMPILE_CACHES = ['*.pyc', '*$py.class']
2012-01-15 18:34:47 +00:00
2010-07-22 14:14:03 +00:00
options(
sphinx=Bunch(builddir='.build'),
2010-07-22 14:14:03 +00:00
)
2010-10-27 07:17:37 +00:00
2010-07-22 14:14:03 +00:00
def sphinx_builddir(options):
2012-11-08 20:20:41 +00:00
return path('docs') / options.sphinx.builddir / 'html'
2010-07-22 14:14:03 +00:00
@task
def clean_docs(options):
sphinx_builddir(options).rmtree()
@task
2012-11-08 20:20:41 +00:00
@needs('clean_docs', 'paver.doctools.html')
2010-07-22 14:14:03 +00:00
def html(options):
2012-11-08 20:20:41 +00:00
destdir = path('Documentation')
2010-07-22 14:14:03 +00:00
destdir.rmtree()
builtdocs = sphinx_builddir(options)
builtdocs.move(destdir)
@task
2012-11-08 20:20:41 +00:00
@needs('paver.doctools.html')
2010-07-22 14:14:03 +00:00
def qhtml(options):
2012-11-08 20:20:41 +00:00
destdir = path('Documentation')
2010-07-22 14:14:03 +00:00
builtdocs = sphinx_builddir(options)
2012-11-08 20:20:41 +00:00
sh('rsync -az %s/ %s' % (builtdocs, destdir))
2010-07-22 14:14:03 +00:00
@task
2012-11-08 20:20:41 +00:00
@needs('clean_docs', 'paver.doctools.html')
2010-07-22 14:14:03 +00:00
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
2012-11-08 20:20:41 +00:00
@needs('clean_docs', 'paver.doctools.html')
2010-07-22 14:14:03 +00:00
def upload_pypi_docs(options):
2012-11-08 20:20:41 +00:00
builtdocs = path('docs') / options.builddir / 'html'
2010-07-22 14:14:03 +00:00
sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs))
@task
2012-11-08 20:20:41 +00:00
@needs('upload_pypi_docs', 'ghdocs')
2010-07-22 14:14:03 +00:00
def upload_docs(options):
pass
@task
def autodoc(options):
2012-11-08 20:20:41 +00:00
sh('extra/release/doc4allmods kombu')
2010-07-22 14:14:03 +00:00
@task
def verifyindex(options):
2012-11-08 20:20:41 +00:00
sh('extra/release/verify-reference-index.sh')
2010-07-22 14:14:03 +00:00
@task
def clean_readme(options):
2012-11-08 20:20:41 +00:00
path('README').unlink()
path('README.rst').unlink()
2010-07-22 14:14:03 +00:00
@task
2012-11-08 20:20:41 +00:00
@needs('clean_readme')
2010-07-22 14:14:03 +00:00
def readme(options):
2012-11-08 20:20:41 +00:00
sh('python extra/release/sphinx-to-rst.py docs/templates/readme.txt \
> README.rst')
sh('ln -sf README.rst README')
2010-07-22 14:14:03 +00:00
@task
@cmdopts([
2012-11-08 20:20:41 +00:00
('custom=', 'C', 'custom version'),
])
2010-07-22 14:14:03 +00:00
def bump(options):
2013-09-12 16:38:45 +00:00
s = ("-- '%s'" % (options.custom, ) if getattr(options, 'custom', None)
else '')
2012-11-08 20:20:41 +00:00
sh('extra/release/bump_version.py \
kombu/__init__.py README.rst %s' % (s, ))
2010-07-22 14:14:03 +00:00
@task
@cmdopts([
2012-11-08 20:20:41 +00:00
('coverage', 'c', 'Enable coverage'),
('quick', 'q', 'Quick test'),
('verbose', 'V', 'Make more noise'),
2010-07-22 14:14:03 +00:00
])
def test(options):
2012-11-08 20:20:41 +00:00
cmd = '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'
2010-07-22 14:14:03 +00:00
sh(cmd)
@task
@cmdopts([
2012-11-08 20:20:41 +00:00
('noerror', 'E', 'Ignore errors'),
])
def flake8(options):
2012-11-08 20:20:41 +00:00
noerror = getattr(options, 'noerror', False)
complexity = getattr(options, 'complexity', 22)
migrations_path = os.path.join('kombu', 'transport', 'django',
'migrations', '0.+?\.py')
sh("""flake8 kombu | perl -mstrict -mwarnings -nle'
my $ignore = (m/too complex \((\d+)\)/ && $1 le %s)
|| (m{^%s});
if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
}{exit $FOUND_FLAKE;
'""" % (complexity, migrations_path), ignore_error=noerror)
2013-01-17 13:50:01 +00:00
2011-09-22 16:10:13 +00:00
@task
@cmdopts([
2012-11-08 20:20:41 +00:00
('noerror', 'E', 'Ignore errors'),
2011-09-22 16:10:13 +00:00
])
def flakeplus(options):
2012-11-08 20:20:41 +00:00
noerror = getattr(options, 'noerror', False)
sh('flakeplus kombu --2.6',
2011-09-22 16:10:13 +00:00
ignore_error=noerror)
@task
@cmdopts([
2012-11-08 20:20:41 +00:00
('noerror', 'E', 'Ignore errors'),
2011-09-22 16:10:13 +00:00
])
def flakes(options):
flake8(options)
flakeplus(options)
2010-07-22 14:14:03 +00:00
@task
@cmdopts([
2012-11-08 20:20:41 +00:00
('noerror', 'E', 'Ignore errors'),
2010-07-22 14:14:03 +00:00
])
def pep8(options):
2012-11-08 20:20:41 +00:00
noerror = getattr(options, 'noerror', False)
2010-12-18 10:52:25 +00:00
return sh("""find kombu -name "*.py" | xargs pep8 | perl -nle'\
2010-07-22 14:14:03 +00:00
print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
@task
def removepyc(options):
2012-11-08 20:20:41 +00:00
sh('find . -type f -a \\( %s \\) | xargs rm' % (
' -o '.join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
sh('find . -type d -name "__pycache__" | xargs rm -r')
2010-07-22 14:14:03 +00:00
@task
2012-11-08 20:20:41 +00:00
@needs('removepyc')
2010-07-22 14:14:03 +00:00
def gitclean(options):
2012-11-08 20:20:41 +00:00
sh('git clean -xdn')
2010-07-22 14:14:03 +00:00
@task
2012-11-08 20:20:41 +00:00
@needs('removepyc')
2010-07-22 14:14:03 +00:00
def gitcleanforce(options):
2012-11-08 20:20:41 +00:00
sh('git clean -xdf')
2010-07-22 14:14:03 +00:00
@task
2012-11-08 20:20:41 +00:00
@needs('flakes', 'autodoc', 'verifyindex', 'test', 'gitclean')
2010-07-22 14:14:03 +00:00
def releaseok(options):
pass
@task
2012-11-08 20:20:41 +00:00
@needs('releaseok', 'removepyc', 'upload_docs')
2010-07-22 14:14:03 +00:00
def release(options):
pass