/pavement.py

https://github.com/rafaduran/kombu · Python · 190 lines · 143 code · 47 blank · 0 comment · 6 complexity · d4f21fd37aed0f87958924f20c919a79 MD5 · raw file

  1. import os
  2. from paver.easy import * # noqa
  3. from paver import doctools # noqa
  4. from paver.setuputils import setup # noqa
  5. PYCOMPILE_CACHES = ['*.pyc', '*$py.class']
  6. options(
  7. sphinx=Bunch(builddir='.build'),
  8. )
  9. def sphinx_builddir(options):
  10. return path('docs') / options.sphinx.builddir / 'html'
  11. @task
  12. def clean_docs(options):
  13. sphinx_builddir(options).rmtree()
  14. @task
  15. @needs('clean_docs', 'paver.doctools.html')
  16. def html(options):
  17. destdir = path('Documentation')
  18. destdir.rmtree()
  19. builtdocs = sphinx_builddir(options)
  20. builtdocs.move(destdir)
  21. @task
  22. @needs('paver.doctools.html')
  23. def qhtml(options):
  24. destdir = path('Documentation')
  25. builtdocs = sphinx_builddir(options)
  26. sh('rsync -az %s/ %s' % (builtdocs, destdir))
  27. @task
  28. @needs('clean_docs', 'paver.doctools.html')
  29. def ghdocs(options):
  30. builtdocs = sphinx_builddir(options)
  31. sh("git checkout gh-pages && \
  32. cp -r %s/* . && \
  33. git commit . -m 'Rendered documentation for Github Pages.' && \
  34. git push origin gh-pages && \
  35. git checkout master" % builtdocs)
  36. @task
  37. @needs('clean_docs', 'paver.doctools.html')
  38. def upload_pypi_docs(options):
  39. builtdocs = path('docs') / options.builddir / 'html'
  40. sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs))
  41. @task
  42. @needs('upload_pypi_docs', 'ghdocs')
  43. def upload_docs(options):
  44. pass
  45. @task
  46. def autodoc(options):
  47. sh('extra/release/doc4allmods kombu')
  48. @task
  49. def verifyindex(options):
  50. sh('extra/release/verify-reference-index.sh')
  51. @task
  52. def clean_readme(options):
  53. path('README').unlink()
  54. path('README.rst').unlink()
  55. @task
  56. @needs('clean_readme')
  57. def readme(options):
  58. sh('python extra/release/sphinx-to-rst.py docs/templates/readme.txt \
  59. > README.rst')
  60. sh('ln -sf README.rst README')
  61. @task
  62. @cmdopts([
  63. ('custom=', 'C', 'custom version'),
  64. ])
  65. def bump(options):
  66. s = "-- '%s'" % (options.custom, ) \
  67. if getattr(options, 'custom', None) else ''
  68. sh('extra/release/bump_version.py \
  69. kombu/__init__.py README.rst %s' % (s, ))
  70. @task
  71. @cmdopts([
  72. ('coverage', 'c', 'Enable coverage'),
  73. ('quick', 'q', 'Quick test'),
  74. ('verbose', 'V', 'Make more noise'),
  75. ])
  76. def test(options):
  77. cmd = 'nosetests'
  78. if getattr(options, 'coverage', False):
  79. cmd += ' --with-coverage3'
  80. if getattr(options, 'quick', False):
  81. cmd = 'QUICKTEST=1 SKIP_RLIMITS=1 %s' % cmd
  82. if getattr(options, 'verbose', False):
  83. cmd += ' --verbosity=2'
  84. sh(cmd)
  85. @task
  86. @cmdopts([
  87. ('noerror', 'E', 'Ignore errors'),
  88. ])
  89. def flake8(options):
  90. noerror = getattr(options, 'noerror', False)
  91. complexity = getattr(options, 'complexity', 22)
  92. migrations_path = os.path.join('kombu', 'transport', 'django',
  93. 'migrations', '0.+?\.py')
  94. sh("""flake8 kombu | perl -mstrict -mwarnings -nle'
  95. my $ignore = (m/too complex \((\d+)\)/ && $1 le %s)
  96. || (m{^%s});
  97. if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
  98. }{exit $FOUND_FLAKE;
  99. '""" % (complexity, migrations_path), ignore_error=noerror)
  100. @task
  101. @cmdopts([
  102. ('noerror', 'E', 'Ignore errors'),
  103. ])
  104. def flakeplus(options):
  105. noerror = getattr(options, 'noerror', False)
  106. sh('flakeplus kombu --2.6',
  107. ignore_error=noerror)
  108. @task
  109. @cmdopts([
  110. ('noerror', 'E', 'Ignore errors'),
  111. ])
  112. def flakes(options):
  113. flake8(options)
  114. flakeplus(options)
  115. @task
  116. @cmdopts([
  117. ('noerror', 'E', 'Ignore errors'),
  118. ])
  119. def pep8(options):
  120. noerror = getattr(options, 'noerror', False)
  121. return sh("""find kombu -name "*.py" | xargs pep8 | perl -nle'\
  122. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  123. @task
  124. def removepyc(options):
  125. sh('find . -type f -a \\( %s \\) | xargs rm' % (
  126. ' -o '.join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
  127. sh('find . -type d -name "__pycache__" | xargs rm -r')
  128. @task
  129. @needs('removepyc')
  130. def gitclean(options):
  131. sh('git clean -xdn')
  132. @task
  133. @needs('removepyc')
  134. def gitcleanforce(options):
  135. sh('git clean -xdf')
  136. @task
  137. @needs('flakes', 'autodoc', 'verifyindex', 'test', 'gitclean')
  138. def releaseok(options):
  139. pass
  140. @task
  141. @needs('releaseok', 'removepyc', 'upload_docs')
  142. def release(options):
  143. pass