pavement.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import sys
  2. from paver.easy import *
  3. from paver import doctools
  4. from paver.setuputils import setup
  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("%s setup.py upload_sphinx --upload-dir='%s'" % (
  41. sys.executable, builtdocs))
  42. @task
  43. @needs("upload_pypi_docs", "ghdocs")
  44. def upload_docs(options):
  45. pass
  46. @task
  47. def autodoc(options):
  48. sh("contrib/release/doc4allmods celery")
  49. @task
  50. def verifyindex(options):
  51. sh("contrib/release/verify-reference-index.sh")
  52. @task
  53. def verifyconfigref(options):
  54. sh("PYTHONPATH=. %s contrib/release/verify_config_reference.py \
  55. docs/configuration.rst" % (sys.executable, ))
  56. @task
  57. @cmdopts([
  58. ("noerror", "E", "Ignore errors"),
  59. ])
  60. def flake8(options):
  61. noerror = getattr(options, "noerror", False)
  62. complexity = getattr(options, "complexity", 22)
  63. sh("""flake8 celery | perl -mstrict -mwarnings -nle'
  64. my $ignore = m/too complex \((\d+)\)/ && $1 le %s;
  65. if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
  66. }{exit $FOUND_FLAKE;
  67. '""" % (complexity, ), ignore_error=noerror)
  68. @task
  69. @cmdopts([
  70. ("noerror", "E", "Ignore errors"),
  71. ])
  72. def flakeplus(options):
  73. noerror = getattr(options, "noerror", False)
  74. sh("flakeplus celery", ignore_error=noerror)
  75. @task
  76. @cmdopts([
  77. ("noerror", "E", "Ignore errors")
  78. ])
  79. def flakes(options):
  80. flake8(options)
  81. flakeplus(options)
  82. @task
  83. def clean_readme(options):
  84. path("README").unlink()
  85. path("README.rst").unlink()
  86. @task
  87. @needs("clean_readme")
  88. def readme(options):
  89. sh("%s contrib/release/sphinx-to-rst.py docs/templates/readme.txt \
  90. > README.rst" % (sys.executable, ))
  91. @task
  92. def bump(options):
  93. sh("contrib/release/bump_version.py \
  94. celery/__init__.py docs/includes/introduction.txt \
  95. --before-commit='paver readme'")
  96. @task
  97. @cmdopts([
  98. ("coverage", "c", "Enable coverage"),
  99. ("quick", "q", "Quick test"),
  100. ("verbose", "V", "Make more noise"),
  101. ])
  102. def test(options):
  103. cmd = "CELERY_LOADER=default nosetests"
  104. if getattr(options, "coverage", False):
  105. cmd += " --with-coverage3"
  106. if getattr(options, "quick", False):
  107. cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd
  108. if getattr(options, "verbose", False):
  109. cmd += " --verbosity=2"
  110. sh(cmd)
  111. @task
  112. @cmdopts([
  113. ("noerror", "E", "Ignore errors"),
  114. ])
  115. def pep8(options):
  116. noerror = getattr(options, "noerror", False)
  117. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  118. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  119. @task
  120. def removepyc(options):
  121. sh("find . -type f -a \\( %s \\) | xargs rm" % (
  122. " -o ".join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
  123. @task
  124. @needs("removepyc")
  125. def gitclean(options):
  126. sh("git clean -xdn")
  127. @task
  128. @needs("removepyc")
  129. def gitcleanforce(options):
  130. sh("git clean -xdf")
  131. @task
  132. @needs("flakes", "autodoc", "verifyindex",
  133. "verifyconfigref", "test", "gitclean")
  134. def releaseok(options):
  135. pass
  136. @task
  137. @needs("releaseok", "removepyc", "upload_docs")
  138. def release(options):
  139. pass
  140. @task
  141. def verify_authors(options):
  142. sh("git shortlog -se | cut -f2 | contrib/release/attribution.py")
  143. @task
  144. def coreloc(options):
  145. sh("xargs sloccount < contrib/release/core-modules.txt")
  146. @task
  147. def testloc(options):
  148. sh("sloccount celery/tests")
  149. @task
  150. def loc(options):
  151. sh("sloccount celery")