-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtasks.py
70 lines (55 loc) · 1.81 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# !usr/bin/env python
# -*- coding: utf-8 -*-
#
# Licensed under a 3-clause BSD license.
#
# @Author: Brian Cherinka
# @Date: 2017-09-27 11:08:07
# @Last modified by: José Sánchez-Gallego (gallegoj@uw.edu)
# @Last Modified time: 2017-09-27 11:20:46
from __future__ import print_function, division, absolute_import
import os
from invoke import Collection, task
# This file contains tasks that can be easily run from the shell terminal using
# the Invoke python package
# If you do not have invoke, install it with pip install
# To list the tasks available, type invoke --list from the top-level repo directory
@task
def clean_docs(ctx):
''' Cleans up the Sphinx docs '''
print('Cleaning the docs')
ctx.run("rm -rf docs/sphinx/_build", pty=True)
@task(clean_docs)
def build_docs(ctx):
''' Builds the Sphinx docs '''
print('Building the docs')
os.chdir('docs/sphinx')
ctx.run("make html", pty=True)
@task
def show_docs(ctx):
"""Shows the Sphinx docs"""
print('Showing the docs')
os.chdir('docs/sphinx/_build/html')
ctx.run('open ./index.html', pty=True)
@task
def clean(ctx):
''' Cleans up the crap before a Pip build '''
print('Cleaning')
ctx.run("rm -rf htmlcov", pty=True)
ctx.run("rm -rf build", pty=True)
ctx.run("rm -rf dist", pty=True)
ctx.run("rm -rf lvmsurveysim.egg-info", pty=True)
@task(clean)
def deploy(ctx):
''' Deploy the project to pypi '''
print('Deploying to Pypi!')
ctx.run("python setup.py sdist bdist_wheel --universal", pty=True)
ctx.run("twine upload dist/*", pty=True)
# create a collection of tasks
ns = Collection(clean, deploy)
# create a sub-collection for the doc tasks
docs = Collection('docs')
docs.add_task(build_docs, 'build')
docs.add_task(clean_docs, 'clean')
docs.add_task(show_docs, 'show')
ns.add_collection(docs)