pavement.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. from paver.easy import *
  2. from paver import doctools
  3. from paver.setuputils import setup
  4. options(
  5. sphinx=Bunch(builddir=".build"),
  6. )
  7. def sphinx_builddir(options):
  8. return path("docs") / options.sphinx.builddir / "html"
  9. @task
  10. def clean_docs(options):
  11. sphinx_builddir(options).rmtree()
  12. @task
  13. @needs("clean_docs", "paver.doctools.html")
  14. def html(options):
  15. destdir = path("Documentation")
  16. destdir.rmtree()
  17. builtdocs = sphinx_builddir(options)
  18. builtdocs.move(destdir)
  19. @task
  20. @needs("paver.doctools.html")
  21. def qhtml(options):
  22. destdir = path("Documentation")
  23. builtdocs = sphinx_builddir(options)
  24. sh("rsync -az %s/ %s" % (builtdocs, destdir))
  25. @task
  26. @needs("clean_docs", "paver.doctools.html")
  27. def ghdocs(options):
  28. builtdocs = sphinx_builddir(options)
  29. sh("sphinx-to-github", cwd=builtdocs)
  30. sh("git checkout gh-pages && \
  31. cp -r %s/* . && \
  32. git commit . -m 'Rendered documentation for Github Pages.' && \
  33. git push origin gh-pages && \
  34. git checkout master" % builtdocs)
  35. @task
  36. @needs("clean_docs", "paver.doctools.html")
  37. def upload_pypi_docs(options):
  38. builtdocs = path("docs") / options.builddir / "html"
  39. sh("python setup.py upload_sphinx --upload-dir='%s'" % (builtdocs))
  40. @task
  41. @needs("upload_pypi_docs", "ghdocs")
  42. def upload_docs(options):
  43. pass
  44. @task
  45. def autodoc(options):
  46. sh("contrib/release/doc4allmods celery")
  47. @task
  48. def verifyindex(options):
  49. sh("contrib/release/verify-reference-index.sh")
  50. @task
  51. def flakes(options):
  52. noerror = getattr(options, "noerror", False)
  53. sh("""find celery -name '*.py' | xargs pyflakes | perl -mstrict -nle'
  54. my $flake = $_;open(my $f, "contrib/release/flakesignore.txt");
  55. my $ignored = 0;
  56. PATTERN: foreach my $p (<$f>) { chomp($p);
  57. if ($p && $flake =~ /$p/m) {
  58. $ignored = 1; last PATTERN; } } close($f);
  59. if (! $ignored) { print $flake; our $FOUND_FLAKE = 1; }
  60. }{exit $FOUND_FLAKE;
  61. '""", ignore_error=noerror)
  62. @task
  63. def clean_readme(options):
  64. path("README").unlink()
  65. path("README.rst").unlink()
  66. @task
  67. @needs("clean_readme")
  68. def readme(options):
  69. sh("python contrib/release/sphinx-to-rst.py docs/templates/readme.txt \
  70. > README.rst")
  71. sh("ln -sf README.rst README")
  72. @task
  73. def bump(options):
  74. sh("bump -c celery")
  75. @task
  76. @cmdopts([
  77. ("coverage", "c", "Enable coverage"),
  78. ("quick", "q", "Quick test"),
  79. ("verbose", "V", "Make more noise"),
  80. ])
  81. def test(options):
  82. cmd = "CELERY_LOADER=default nosetests"
  83. if getattr(options, "coverage", False):
  84. cmd += " --with-coverage3"
  85. if getattr(options, "quick", False):
  86. cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd
  87. if getattr(options, "verbose", False):
  88. cmd += " --verbosity=2"
  89. sh(cmd)
  90. @task
  91. @cmdopts([
  92. ("noerror", "E", "Ignore errors"),
  93. ])
  94. def pep8(options):
  95. noerror = getattr(options, "noerror", False)
  96. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  97. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  98. @task
  99. def removepyc(options):
  100. sh("find . -name '*.pyc' | xargs rm")
  101. @task
  102. @needs("removepyc")
  103. def gitclean(options):
  104. sh("git clean -xdn")
  105. @task
  106. @needs("removepyc")
  107. def gitcleanforce(options):
  108. sh("git clean -xdf")
  109. @task
  110. @needs("pep8", "flakes", "autodoc", "verifyindex", "test", "gitclean")
  111. def releaseok(options):
  112. pass
  113. @task
  114. @needs("releaseok", "removepyc", "upload_docs")
  115. def release(options):
  116. pass
  117. @task
  118. def coreloc(options):
  119. sh("xargs sloccount < contrib/release/core-modules.txt")
  120. @task
  121. def testloc(options):
  122. sh("sloccount celery/tests")
  123. @task
  124. def loc(options):
  125. sh("sloccount celery")