forked from materialsproject/pymatgen-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
executable file
·91 lines (72 loc) · 2.42 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python
"""
Deployment file to facilitate releases of matgendb.
"""
from __future__ import division
__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2012, The Materials Project"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyue@mit.edu"
__date__ = "Apr 29, 2012"
import glob
import os
from invoke import task
from monty.os import cd
from matgendb import __version__ as ver
@task
def make_doc(ctx):
with cd("docs"):
ctx.run("cp ../CHANGES.rst change_log.rst")
ctx.run("sphinx-apidoc -d 6 -o . -f ../matgendb")
ctx.run("rm matgendb*.tests.rst")
for f in glob.glob("*.rst"):
if f.startswith('matgendb') and f.endswith('rst'):
newoutput = []
suboutput = []
subpackage = False
with open(f, 'r') as fid:
for line in fid:
clean = line.strip()
if clean == "Subpackages":
subpackage = True
if not subpackage and not clean.endswith("tests"):
newoutput.append(line)
else:
if not clean.endswith("tests"):
suboutput.append(line)
if clean.startswith("pymatgen") and not clean.endswith("tests"):
newoutput.extend(suboutput)
subpackage = False
suboutput = []
with open(f, 'w') as fid:
fid.write("".join(newoutput))
ctx.run("make html")
ctx.run("cp _static/* _build/html/_static")
# Avoid ths use of jekyll so that _dir works as intended.
ctx.run("touch _build/html/.nojekyll")
@task
def update_doc(ctx):
with cd("docs/_build/html/"):
ctx.run("git pull")
make_doc(ctx)
with cd("docs/_build/html/"):
ctx.run("git add .")
ctx.run("git commit -a -m \"Update dev docs\"")
ctx.run("git push origin gh-pages")
@task
def publish(ctx):
ctx.run("python setup.py release")
@task
def test(ctx):
ctx.run("nosetests")
@task
def setver(ctx):
ctx.run("sed s/version=.*,/version=\\\"{}\\\",/ setup.py > newsetup".format(ver))
ctx.run("mv newsetup setup.py")
@task
def release(ctx):
setver(ctx)
#test(ctx)
make_doc(ctx)
publish(ctx)