pavement.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import sys
  2. from paver.easy import task, sh, cmdopts, path, needs, options, Bunch
  3. from paver import doctools # noqa
  4. from paver.setuputils import setup # noqa
  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 {0}/ {1}'.format(builtdocs, destdir))
  27. @task
  28. def autodoc(options):
  29. sh('extra/release/doc4allmods celery')
  30. @task
  31. def verifyindex(options):
  32. sh('extra/release/verify-reference-index.sh')
  33. @task
  34. def verifyconfigref(options):
  35. sh('PYTHONPATH=. {0} extra/release/verify_config_reference.py \
  36. docs/configuration.rst'.format(sys.executable))
  37. @task
  38. @cmdopts([
  39. ('noerror', 'E', 'Ignore errors'),
  40. ])
  41. def flake8(options):
  42. noerror = getattr(options, 'noerror', False)
  43. complexity = getattr(options, 'complexity', 22)
  44. sh("""flake8 celery | perl -mstrict -mwarnings -nle'
  45. my $ignore = m/too complex \((\d+)\)/ && $1 le {0};
  46. if (! $ignore) {{ print STDERR; our $FOUND_FLAKE = 1 }}
  47. }}{{exit $FOUND_FLAKE;
  48. '""".format(complexity), ignore_error=noerror)
  49. @task
  50. @cmdopts([
  51. ('noerror', 'E', 'Ignore errors'),
  52. ])
  53. def flakeplus(options):
  54. noerror = getattr(options, 'noerror', False)
  55. sh('flakeplus celery --2.6', ignore_error=noerror)
  56. @task
  57. @cmdopts([
  58. ('noerror', 'E', 'Ignore errors')
  59. ])
  60. def flakes(options):
  61. flake8(options)
  62. flakeplus(options)
  63. @task
  64. def clean_readme(options):
  65. path('README').unlink_p()
  66. path('README.rst').unlink_p()
  67. @task
  68. @needs('clean_readme')
  69. def readme(options):
  70. sh('{0} extra/release/sphinx-to-rst.py docs/templates/readme.txt \
  71. > README.rst'.format(sys.executable))
  72. @task
  73. def bump(options):
  74. sh("extra/release/bump_version.py \
  75. celery/__init__.py docs/includes/introduction.txt \
  76. --before-commit='paver readme'")
  77. @task
  78. @cmdopts([
  79. ('coverage', 'c', 'Enable coverage'),
  80. ('verbose', 'V', 'Make more noise'),
  81. ])
  82. def test(options):
  83. cmd = 'CELERY_LOADER=default nosetests'
  84. if getattr(options, 'coverage', False):
  85. cmd += ' --with-coverage3'
  86. if getattr(options, 'verbose', False):
  87. cmd += ' --verbosity=2'
  88. sh(cmd)
  89. @task
  90. @cmdopts([
  91. ('noerror', 'E', 'Ignore errors'),
  92. ])
  93. def pep8(options):
  94. noerror = getattr(options, 'noerror', False)
  95. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  96. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  97. @task
  98. def removepyc(options):
  99. sh('find . -type f -a \\( {0} \\) | xargs rm'.format(
  100. ' -o '.join("-name '{0}'".format(pat) for pat in PYCOMPILE_CACHES)))
  101. sh('find . -type d -name "__pycache__" | xargs rm -r')
  102. @task
  103. def update_graphs(options, dest='docs/images/worker_graph_full.png'):
  104. sh('celery graph bootsteps | dot -Tpng -o {dest}'.format(
  105. dest=dest,
  106. ))
  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('flakes', 'autodoc', 'verifyindex',
  117. 'verifyconfigref', 'test', 'gitclean')
  118. def releaseok(options):
  119. pass
  120. @task
  121. def verify_authors(options):
  122. sh('git shortlog -se | cut -f2 | extra/release/attribution.py')
  123. @task
  124. def testloc(options):
  125. sh('sloccount celery/tests')
  126. @task
  127. def loc(options):
  128. sh('sloccount celery')