pavement.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 {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()
  66. path('README.rst').unlink()
  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. ('quick', 'q', 'Quick test'),
  81. ('verbose', 'V', 'Make more noise'),
  82. ])
  83. def test(options):
  84. cmd = 'CELERY_LOADER=default nosetests'
  85. if getattr(options, 'coverage', False):
  86. cmd += ' --with-coverage3'
  87. if getattr(options, 'quick', False):
  88. cmd = 'QUICKTEST=1 SKIP_RLIMITS=1 {0}'.format(cmd)
  89. if getattr(options, 'verbose', False):
  90. cmd += ' --verbosity=2'
  91. sh(cmd)
  92. @task
  93. @cmdopts([
  94. ('noerror', 'E', 'Ignore errors'),
  95. ])
  96. def pep8(options):
  97. noerror = getattr(options, 'noerror', False)
  98. return sh("""find . -name "*.py" | xargs pep8 | perl -nle'\
  99. print; $a=1 if $_}{exit($a)'""", ignore_error=noerror)
  100. @task
  101. def removepyc(options):
  102. sh('find . -type f -a \\( {0} \\) | xargs rm'.format(
  103. ' -o '.join("-name '{0}'".format(pat) for pat in PYCOMPILE_CACHES)))
  104. sh('find . -type d -name "__pycache__" | xargs rm -r')
  105. @task
  106. def update_graphs(options):
  107. sh('celery worker_graph | dot -Tpng -o docs/images/worker_graph.png')
  108. sh('celery consumer_graph | dot -Tpng -o docs/images/consumer_graph.png')
  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('flakes', 'autodoc', 'verifyindex',
  119. 'verifyconfigref', 'test', 'gitclean')
  120. def releaseok(options):
  121. pass
  122. @task
  123. def verify_authors(options):
  124. sh('git shortlog -se | cut -f2 | extra/release/attribution.py')
  125. @task
  126. def coreloc(options):
  127. sh('xargs sloccount < extra/release/core-modules.txt')
  128. @task
  129. def testloc(options):
  130. sh('sloccount celery/tests')
  131. @task
  132. def loc(options):
  133. sh('sloccount celery')