pavement.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. def clean_contributing(options):
  69. path('CONTRIBUTING.rst').unlink_p()
  70. @task
  71. @needs('clean_readme')
  72. def readme(options):
  73. sh('{0} extra/release/sphinx-to-rst.py docs/templates/readme.txt \
  74. > README.rst'.format(sys.executable))
  75. @task
  76. @needs('clean_contributing')
  77. def contributing(options):
  78. sh('{0} extra/release/sphinx-to-rst.py docs/contributing.rst \
  79. > CONTRIBUTING.rst'.format(sys.executable))
  80. @task
  81. def bump(options):
  82. sh("extra/release/bump_version.py \
  83. celery/__init__.py docs/includes/introduction.txt \
  84. --before-commit='paver readme'")
  85. @task
  86. @cmdopts([
  87. ('coverage', 'c', 'Enable coverage'),
  88. ('verbose', 'V', 'Make more noise'),
  89. ])
  90. def test(options):
  91. cmd = 'CELERY_LOADER=default nosetests'
  92. if getattr(options, 'coverage', False):
  93. cmd += ' --with-coverage'
  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 \\( {0} \\) | xargs rm'.format(
  108. ' -o '.join("-name '{0}'".format(pat) for pat in PYCOMPILE_CACHES)))
  109. sh('find . -type d -name "__pycache__" | xargs rm -r')
  110. @task
  111. def update_graphs(options, dest='docs/images/worker_graph_full.png'):
  112. sh('celery graph bootsteps | dot -Tpng -o {dest}'.format(
  113. dest=dest,
  114. ))
  115. @task
  116. @needs('removepyc')
  117. def gitclean(options):
  118. sh('git clean -xdn')
  119. @task
  120. @needs('removepyc')
  121. def gitcleanforce(options):
  122. sh('git clean -xdf')
  123. @task
  124. @needs('flakes', 'autodoc', 'verifyindex',
  125. 'verifyconfigref', 'test', 'gitclean')
  126. def releaseok(options):
  127. pass
  128. @task
  129. def verify_authors(options):
  130. sh('git shortlog -se | cut -f2 | extra/release/attribution.py')
  131. @task
  132. def testloc(options):
  133. sh('sloccount celery/tests')
  134. @task
  135. def loc(options):
  136. sh('sloccount celery')