Utility script to help create sha256 hashes
[releng-anteater.git] / tasks.py
1 # -*- coding: utf-8 -*-
2 from __future__ import absolute_import
3 from __future__ import print_function
4 import os
5 import sys
6
7 from invoke import task, run
8
9 docs_dir = 'docs'
10 build_dir = os.path.join(docs_dir, '_build')
11
12
13 @task
14 def test(ctx):
15     run('python setup.py test', pty=True)
16
17
18 @task
19 def clean(ctx):
20     ctx.run("rm -rf build")
21     ctx.run("rm -rf dist")
22     ctx.run("rm -rf anteater.egg-info")
23     clean_docs(ctx)
24     print("Cleaned up.")
25
26
27 @task
28 def clean_docs(ctx):
29     ctx.run("rm -rf %s" % build_dir)
30
31
32 @task
33 def browse_docs(ctx):
34     ctx.run("open %s" % os.path.join(build_dir, 'index.html'))
35
36
37 @task
38 def build_docs(ctx, clean=False, browse=False):
39     if clean:
40         clean_docs()
41     ctx.run("sphinx-build %s %s" % (docs_dir, build_dir), pty=True)
42     if browse:
43         browse_docs()
44
45
46 @task
47 def readme(ctx, browse=False):
48     ctx.run('rst2html.py README.rst > README.html')
49
50
51 @task
52 def build(ctx):
53     """Build source distribution and wheels."""
54     ctx.run('python setup.py sdist bdist_wheel')
55
56
57 @task
58 def publish(ctx, test=False):
59     """Publish to the cheeseshop.
60
61     This command follows the Python packaging guidelines:
62     https://packaging.python.org/tutorials/distributing-packages
63
64     Information on configuration required for '--test' can be found
65     here: https://wiki.python.org/moin/TestPyPI
66
67     Before uploading please ensure you've signed the release using:
68
69       gpg --detach-sign -a dist/package-1.0.1.tar.gz
70     """
71     if test:
72         ctx.run('twine upload -r test dist/*')
73     else:
74         ctx.run("twine upload dist/*")