pavement.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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("sphinx-to-github", cwd=builtdocs)
  32. sh("git checkout gh-pages && \
  33. cp -r %s/* . && \
  34. git commit . -m 'Rendered documentation for Github Pages.' && \
  35. git push origin gh-pages && \
  36. git checkout master" % builtdocs)
  37. @task
  38. @needs("clean_docs", "paver.doctools.html")
  39. def upload_pypi_docs(options):
  40. builtdocs = path("docs") / options.builddir / "html"
  41. sh("%s setup.py upload_sphinx --upload-dir='%s'" % (
  42. sys.executable, builtdocs))
  43. @task
  44. @needs("upload_pypi_docs", "ghdocs")
  45. def upload_docs(options):
  46. pass
  47. @task
  48. def autodoc(options):
  49. sh("contrib/release/doc4allmods celery")
  50. @task
  51. def verifyindex(options):
  52. sh("contrib/release/verify-reference-index.sh")
  53. @task
  54. def verifyconfigref(options):
  55. sh("PYTHONPATH=. %s contrib/release/verify_config_reference.py \
  56. docs/configuration.rst" % (sys.executable, ))
  57. @task
  58. @cmdopts([
  59. ("noerror", "E", "Ignore errors"),
  60. ])
  61. def flake8(options):
  62. noerror = getattr(options, "noerror", False)
  63. complexity = getattr(options, "complexity", 22)
  64. sh("""flake8 celery | perl -mstrict -mwarnings -nle'
  65. my $ignore = m/too complex \((\d+)\)/ && $1 le %s;
  66. if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
  67. }{exit $FOUND_FLAKE;
  68. '""" % (complexity, ), ignore_error=noerror)
  69. @task
  70. def clean_readme(options):
  71. path("README").unlink()
  72. path("README.rst").unlink()
  73. @task
  74. @needs("clean_readme")
  75. def readme(options):
  76. sh("%s contrib/release/sphinx-to-rst.py docs/templates/readme.txt \
  77. > README.rst" % (sys.executable, ))
  78. sh("ln -sf README.rst README")
  79. @task
  80. def bump(options):
  81. sh("bump -c celery")
  82. @task
  83. @cmdopts([
  84. ("coverage", "c", "Enable coverage"),
  85. ("quick", "q", "Quick test"),
  86. ("verbose", "V", "Make more noise"),
  87. ])
  88. def test(options):
  89. cmd = "CELERY_LOADER=default nosetests"
  90. if getattr(options, "coverage", False):
  91. cmd += " --with-coverage3"
  92. if getattr(options, "quick", False):
  93. cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd
  94. if getattr(options, "verbose", False):
  95. cmd += " --verbosity=2"
  96. sh(cmd)
  97. @task
  98. @cmdopts([
  99. ("noerror", "E", "Ignore errors"),
  100. ])
  101. def pep8(options):
  102. noerror = getattr(options, "noerror", False)
  103. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  104. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  105. @task
  106. def removepyc(options):
  107. sh("find . -type f -a \\( %s \\) | xargs rm" % (
  108. " -o ".join("-name '%s'" % (pat, ) for pat in PYCOMPILE_CACHES), ))
  109. @task
  110. @needs("removepyc")
  111. def gitclean(options):
  112. sh("git clean -xdn")
  113. @task
  114. @needs("removepyc")
  115. def gitcleanforce(options):
  116. sh("git clean -xdf")
  117. @task
  118. @needs("flake8", "autodoc", "verifyindex",
  119. "verifyconfigref", "test", "gitclean")
  120. def releaseok(options):
  121. pass
  122. @task
  123. @needs("releaseok", "removepyc", "upload_docs")
  124. def release(options):
  125. pass
  126. @task
  127. def coreloc(options):
  128. sh("xargs sloccount < contrib/release/core-modules.txt")
  129. @task
  130. def testloc(options):
  131. sh("sloccount celery/tests")
  132. @task
  133. def loc(options):
  134. sh("sloccount celery")