pavement.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. from __future__ import print_function
  2. import sys
  3. import traceback
  4. from paver.easy import task, sh, cmdopts, path, needs, options, Bunch
  5. from paver import doctools # noqa
  6. from paver.setuputils import setup # noqa
  7. PYCOMPILE_CACHES = ['*.pyc', '*$py.class']
  8. options(
  9. sphinx=Bunch(builddir='.build'),
  10. )
  11. def sphinx_builddir(options):
  12. return path('docs') / options.sphinx.builddir / 'html'
  13. @task
  14. def clean_docs(options):
  15. sphinx_builddir(options).rmtree()
  16. @task
  17. @needs('clean_docs', 'paver.doctools.html')
  18. def html(options):
  19. destdir = path('Documentation')
  20. destdir.rmtree()
  21. builtdocs = sphinx_builddir(options)
  22. builtdocs.move(destdir)
  23. @task
  24. @needs('paver.doctools.html')
  25. def qhtml(options):
  26. destdir = path('Documentation')
  27. builtdocs = sphinx_builddir(options)
  28. sh('rsync -az {0}/ {1}'.format(builtdocs, destdir))
  29. @task
  30. def autodoc(options):
  31. sh('extra/release/doc4allmods celery')
  32. @task
  33. def verifyindex(options):
  34. sh('extra/release/verify-reference-index.sh')
  35. @task
  36. def verifyconfigref(options):
  37. sh('PYTHONPATH=. {0} extra/release/verify_config_reference.py \
  38. docs/configuration.rst'.format(sys.executable))
  39. @task
  40. @cmdopts([
  41. ('noerror', 'E', 'Ignore errors'),
  42. ])
  43. def flake8(options):
  44. noerror = getattr(options, 'noerror', False)
  45. complexity = getattr(options, 'complexity', 22)
  46. sh("""flake8 celery | perl -mstrict -mwarnings -nle'
  47. my $ignore = m/too complex \((\d+)\)/ && $1 le {0};
  48. if (! $ignore) {{ print STDERR; our $FOUND_FLAKE = 1 }}
  49. }}{{exit $FOUND_FLAKE;
  50. '""".format(complexity), ignore_error=noerror)
  51. @task
  52. @cmdopts([
  53. ('noerror', 'E', 'Ignore errors'),
  54. ])
  55. def flakeplus(options):
  56. noerror = getattr(options, 'noerror', False)
  57. sh('flakeplus celery --2.6', ignore_error=noerror)
  58. @task
  59. @cmdopts([
  60. ('noerror', 'E', 'Ignore errors')
  61. ])
  62. def flakes(options):
  63. flake8(options)
  64. flakeplus(options)
  65. @task
  66. def clean_readme(options):
  67. path('README').unlink_p()
  68. path('README.rst').unlink_p()
  69. @task
  70. def clean_contributing(options):
  71. path('CONTRIBUTING.rst').unlink_p()
  72. @task
  73. def verify_readme(options):
  74. with open('README.rst') as fp:
  75. try:
  76. fp.read().encode('ascii')
  77. except Exception:
  78. print('README contains non-ascii characters', file=sys.stderr)
  79. print('Original exception below...', file=sys.stderr)
  80. traceback.print_stack(file=sys.stderr)
  81. sh('false')
  82. @task
  83. @needs('clean_readme')
  84. def readme(options):
  85. sh('{0} extra/release/sphinx-to-rst.py docs/templates/readme.txt \
  86. > README.rst'.format(sys.executable))
  87. verify_readme()
  88. @task
  89. @needs('clean_contributing')
  90. def contributing(options):
  91. sh('{0} extra/release/sphinx-to-rst.py docs/contributing.rst \
  92. > CONTRIBUTING.rst'.format(sys.executable))
  93. @task
  94. def bump(options):
  95. sh("extra/release/bump_version.py \
  96. celery/__init__.py docs/includes/introduction.txt \
  97. --before-commit='paver readme'")
  98. @task
  99. @cmdopts([
  100. ('coverage', 'c', 'Enable coverage'),
  101. ('verbose', 'V', 'Make more noise'),
  102. ])
  103. def test(options):
  104. cmd = 'CELERY_LOADER=default nosetests'
  105. if getattr(options, 'coverage', False):
  106. cmd += ' --with-coverage'
  107. if getattr(options, 'verbose', False):
  108. cmd += ' --verbosity=2'
  109. sh(cmd)
  110. @task
  111. @cmdopts([
  112. ('noerror', 'E', 'Ignore errors'),
  113. ])
  114. def pep8(options):
  115. noerror = getattr(options, 'noerror', False)
  116. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  117. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  118. @task
  119. def removepyc(options):
  120. sh('find . -type f -a \\( {0} \\) | xargs rm'.format(
  121. ' -o '.join("-name '{0}'".format(pat) for pat in PYCOMPILE_CACHES)))
  122. sh('find . -type d -name "__pycache__" | xargs rm -r')
  123. @task
  124. def update_graphs(options, dest='docs/images/worker_graph_full.png'):
  125. sh('celery graph bootsteps | dot -Tpng -o {dest}'.format(
  126. dest=dest,
  127. ))
  128. @task
  129. @needs('removepyc')
  130. def gitclean(options):
  131. sh('git clean -xdn')
  132. @task
  133. @needs('removepyc')
  134. def gitcleanforce(options):
  135. sh('git clean -xdf')
  136. @task
  137. @needs('flakes', 'autodoc', 'verifyindex',
  138. 'verifyconfigref', 'verify_readme', 'test', 'gitclean')
  139. def releaseok(options):
  140. pass
  141. @task
  142. def verify_authors(options):
  143. sh('git shortlog -se | cut -f2 | extra/release/attribution.py')
  144. @task
  145. def testloc(options):
  146. sh('sloccount celery/tests')
  147. @task
  148. def loc(options):
  149. sh('sloccount celery')