forked from coursera-dl/coursera-dl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
90 lines (65 loc) · 1.89 KB
/
fabfile.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
#
# Fabric configuration - http://www.fabfile.org/
#
from __future__ import print_function
import errno
import os
from fabric.api import (env, local, task)
if not os.path.exists('README.rst'):
local('pandoc --from=markdown --to=rst --output=README.rst README.md')
env.projname = local("python setup.py --name", capture=True)
env.version = local("python setup.py --version", capture=True)
def mkdirs(path):
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
@task
def create_rst_doc():
local('pandoc --from=markdown --to=rst --output=README.rst README.md')
@task
def clean():
create_rst_doc()
local("python setup.py clean")
local("rm -rf .tox coursera.egg-info htmlcov build dist README.rst")
local("rm -rf coursera/__pycache__/ coursera/test/__pycache__/")
local("find . -name '*.pyc' -delete")
@task
def build():
create_rst_doc()
local("python setup.py sdist")
local("gpg --detach-sign -a dist/coursera-%s.tar.gz" % env.version)
@task
def rebuild():
clean()
build()
@task
def coverage():
local("py.test coursera/test -v --cov coursera --cov-report html \
--cov-report term-missing")
@task
def pylint():
local("pylint %s tests" % env.projname)
@task
def tox():
local('tox')
@task
def release_check():
"""Check if there is a Git tag already in place"""
tags = local("git tag", capture=True)
tags = set(tags.splitlines())
if env.version in tags:
raise Exception("Already released v. %r" % env.version)
@task
def release():
"""Release a new version"""
release_check()
build()
print("Releasing %s version %s." % (env.projname, env.version))
local("git tag %s" % env.version)
local('twine upload dist/coursera-*.tar.gz*')
local("git push")
local("git push --tags")