pavement.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 flake8(options):
  58. noerror = getattr(options, "noerror", False)
  59. complexity = getattr(options, "complexity", 22)
  60. sh("""flake8 celery | perl -mstrict -mwarnings -nle'
  61. my $ignore = m/too complex \((\d+)\)/ && $1 le %s;
  62. if (! $ignore) { print STDERR; our $FOUND_FLAKE = 1 }
  63. }{exit $FOUND_FLAKE;
  64. '""" % (complexity, ), ignore_error=noerror)
  65. @task
  66. def clean_readme(options):
  67. path("README").unlink()
  68. path("README.rst").unlink()
  69. @task
  70. @needs("clean_readme")
  71. def readme(options):
  72. sh("%s contrib/release/sphinx-to-rst.py docs/templates/readme.txt \
  73. > README.rst" % (sys.executable, ))
  74. sh("ln -sf README.rst README")
  75. @task
  76. def bump(options):
  77. sh("bump -c celery")
  78. @task
  79. @cmdopts([
  80. ("coverage", "c", "Enable coverage"),
  81. ("quick", "q", "Quick test"),
  82. ("verbose", "V", "Make more noise"),
  83. ])
  84. def test(options):
  85. cmd = "CELERY_LOADER=default nosetests"
  86. if getattr(options, "coverage", False):
  87. cmd += " --with-coverage3"
  88. if getattr(options, "quick", False):
  89. cmd = "QUICKTEST=1 SKIP_RLIMITS=1 %s" % cmd
  90. if getattr(options, "verbose", False):
  91. cmd += " --verbosity=2"
  92. sh(cmd)
  93. @task
  94. @cmdopts([
  95. ("noerror", "E", "Ignore errors"),
  96. ])
  97. def pep8(options):
  98. noerror = getattr(options, "noerror", False)
  99. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  100. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  101. @task
  102. def removepyc(options):
  103. sh("find . -name '*.pyc' | xargs rm")
  104. @task
  105. @needs("removepyc")
  106. def gitclean(options):
  107. sh("git clean -xdn")
  108. @task
  109. @needs("removepyc")
  110. def gitcleanforce(options):
  111. sh("git clean -xdf")
  112. @task
  113. @needs("flake8", "autodoc", "verifyindex",
  114. "verifyconfigref", "test", "gitclean")
  115. def releaseok(options):
  116. pass
  117. @task
  118. @needs("releaseok", "removepyc", "upload_docs")
  119. def release(options):
  120. pass
  121. @task
  122. def coreloc(options):
  123. sh("xargs sloccount < contrib/release/core-modules.txt")
  124. @task
  125. def testloc(options):
  126. sh("sloccount celery/tests")
  127. @task
  128. def loc(options):
  129. sh("sloccount celery")