forked from sloria/TextBlob
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
73 lines (61 loc) · 1.52 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
from invoke import task, run
docs_dir = 'docs'
build_dir = os.path.join(docs_dir, '_build')
@task
def test():
run("python run_tests.py", pty=True)
@task
def clean():
run("rm -rf build")
run("rm -rf dist")
run("rm -rf textblob.egg-info")
clean_docs()
print("Cleaned up.")
@task
def clean_docs():
run("rm -rf %s" % build_dir)
@task
def browse_docs():
platform = str(sys.platform).lower()
command_map = {
'darwin': 'open ',
'linux': 'idle ',
'win32': '',
}
cmd = command_map.get(platform)
if cmd:
run("{0}{1}".format(cmd, os.path.join(build_dir, 'index.html')))
else:
print('Unsure how to open the built file on this operating system.')
sys.exit(1)
@task
def docs(clean=False, browse=False):
if clean:
clean_docs()
run("sphinx-build %s %s" % (docs_dir, build_dir), pty=True)
if browse:
browse_docs()
@task
def readme():
run("rst2html.py README.rst > README.html", pty=True)
run("open README.html")
@task
def doctest():
os.chdir(docs_dir)
run("make doctest")
@task
def publish(test=False):
"""Publish to the cheeseshop."""
try:
__import__('wheel')
except ImportError:
print("wheel required. Run `pip install wheel`.")
sys.exit(1)
if test:
run('python setup.py register -r test sdist bdist_wheel upload -r test')
else:
run("python setup.py register sdist bdist_wheel upload")