pavement.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import sys
  2. from paver.easy import *
  3. from paver import doctools
  4. from paver.setuputils import setup
  5. options(
  6. sphinx=Bunch(builddir=".build"),
  7. )
  8. def sphinx_builddir(options):
  9. return path("docs") / options.sphinx.builddir / "html"
  10. @task
  11. def clean_docs(options):
  12. sphinx_builddir(options).rmtree()
  13. @task
  14. @needs("clean_docs", "paver.doctools.html")
  15. def html(options):
  16. destdir = path("Documentation")
  17. destdir.rmtree()
  18. builtdocs = sphinx_builddir(options)
  19. builtdocs.move(destdir)
  20. @task
  21. @needs("paver.doctools.html")
  22. def qhtml(options):
  23. destdir = path("Documentation")
  24. builtdocs = sphinx_builddir(options)
  25. sh("rsync -az %s/ %s" % (builtdocs, destdir))
  26. @task
  27. @needs("clean_docs", "paver.doctools.html")
  28. def ghdocs(options):
  29. builtdocs = sphinx_builddir(options)
  30. sh("sphinx-to-github", cwd=builtdocs)
  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. def flakes(options):
  58. noerror = getattr(options, "noerror", False)
  59. sh("""find celery -name '*.py' | xargs pyflakes | perl -mstrict -nle'
  60. my $flake = $_;open(my $f, "contrib/release/flakesignore.txt");
  61. my $ignored = 0;
  62. PATTERN: foreach my $p (<$f>) { chomp($p);
  63. if ($p && $flake =~ /$p/m) {
  64. $ignored = 1; last PATTERN; } } close($f);
  65. if (! $ignored) { print $flake; our $FOUND_FLAKE = 1; }
  66. }{exit $FOUND_FLAKE;
  67. '""", ignore_error=noerror)
  68. @task
  69. def clean_readme(options):
  70. path("README").unlink()
  71. path("README.rst").unlink()
  72. @task
  73. @needs("clean_readme")
  74. def readme(options):
  75. sh("%s contrib/release/sphinx-to-rst.py docs/templates/readme.txt \
  76. > README.rst" % (sys.executable, ))
  77. sh("ln -sf README.rst README")
  78. @task
  79. def bump(options):
  80. sh("bump -c celery")
  81. @task
  82. @cmdopts([
  83. ("coverage", "c", "Enable coverage"),
  84. ("quick", "q", "Quick test"),
  85. ("verbose", "V", "Make more noise"),
  86. ])
  87. def test(options):
  88. cmd = "CELERY_LOADER=default nosetests"
  89. if getattr(options, "coverage", False):
  90. cmd += " --with-coverage3"
  91. if getattr(options, "quick", False):
  92. cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd
  93. if getattr(options, "verbose", False):
  94. cmd += " --verbosity=2"
  95. sh(cmd)
  96. @task
  97. @cmdopts([
  98. ("noerror", "E", "Ignore errors"),
  99. ])
  100. def pep8(options):
  101. noerror = getattr(options, "noerror", False)
  102. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  103. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  104. @task
  105. def removepyc(options):
  106. sh("find . -name '*.pyc' | xargs rm")
  107. @task
  108. @needs("removepyc")
  109. def gitclean(options):
  110. sh("git clean -xdn")
  111. @task
  112. @needs("removepyc")
  113. def gitcleanforce(options):
  114. sh("git clean -xdf")
  115. @task
  116. @needs("pep8", "flakes", "autodoc", "verifyindex",
  117. "verifyconfigref", "test", "gitclean")
  118. def releaseok(options):
  119. pass
  120. @task
  121. @needs("releaseok", "removepyc", "upload_docs")
  122. def release(options):
  123. pass
  124. @task
  125. def coreloc(options):
  126. sh("xargs sloccount < contrib/release/core-modules.txt")
  127. @task
  128. def testloc(options):
  129. sh("sloccount celery/tests")
  130. @task
  131. def loc(options):
  132. sh("sloccount celery")