-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpavement.py
More file actions
193 lines (172 loc) · 6.09 KB
/
pavement.py
File metadata and controls
193 lines (172 loc) · 6.09 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# ============================================================================
# PAVER MAKEFILE: pavement.py example
# ============================================================================
# REQUIRES: paver >= 1.2
# DESCRIPTION:
# Provides platform-neutral "Makefile" for simple, project-specific tasks.
#
# USAGE:
# paver TASK [OPTIONS...]
# paver help -- Show all supported commands/tasks.
# paver clean -- Cleanup project workspace.
# paver test -- Run all tests (unittests, examples).
#
# SEE ALSO:
# * http://pypi.python.org/pypi/Paver/
# * http://www.blueskyonmars.com/projects/paver/
# ============================================================================
from paver.easy import *
import os
sys.path.insert(0, ".")
# -- USE PAVER EXTENSIONS: tasks, utility functions
from _paver_ext.pip_download import download_deps, localpi
from _paver_ext.python_checker import pychecker, pylint
from _paver_ext.python_requirements import read_requirements
from _paver_ext.paver_consume_args import Cmdline
from _paver_ext import paver_require, paver_patch
paver_require.min_version("1.2")
paver_patch.ensure_path_with_pmethods(path)
paver_patch.ensure_path_with_smethods(path)
# ----------------------------------------------------------------------------
# PROJECT CONFIGURATION (for sdist/setup mostly):
# ----------------------------------------------------------------------------
NAME = "parse_type"
# ----------------------------------------------------------------------------
# TASK CONFIGURATION:
# ----------------------------------------------------------------------------
options(
# sphinx=Bunch(
# # docroot=".",
# sourcedir= "docs",
# destdir = "../build/docs"
# # XXX-behave: builddir="../build/docs"
# ),
minilib=Bunch(
extra_files=[ 'doctools', 'virtual' ]
),
pychecker = Bunch(default_args=NAME),
pylint = Bunch(default_args=NAME),
clean = Bunch(
dirs = [
".cache",
".tox", #< tox build subtree.
"build", "dist", #< python setup temporary build dir.
"tmp",
],
files = [
".coverage",
"paver-minilib.zip",
],
walkdirs_patterns = [
"__pycache__", #< Python compiled objects cache.
"*.egg-info",
],
walkfiles_patterns = [
"*.pyc", "*.pyo", "*$py.class",
"*.bak", "*.log", "*.tmp",
".coverage.*",
"pylint_*.txt", "pychecker_*.txt",
".DS_Store", "*.~*~", #< MACOSX
],
),
pip = Bunch(
requirements_files=[
"requirements/all.txt",
],
# download_dir="downloads",
download_dir= path("$HOME/.pip/downloads").expandvars(),
),
)
# ----------------------------------------------------------------------------
# TASKS:
# ----------------------------------------------------------------------------
@task
@consume_args
def default(args):
"""Default task, called when no task is provided (default: init)."""
def help_function(): pass
# paver.tasks.help(args, help_function)
call_task("help", args=args)
# @task
# @consume_args
# def docs(args):
# """Generate the documentation: html, pdf, ... (default: html)"""
# builders = args
# if not builders:
# builders = [ "html" ]
#
# call_task("prepare_docs")
# for builder in builders:
# sphinx_build(builder)
#
# @task
# def linkcheck():
# """Check hyperlinks in documentation."""
# sphinx_build("linkcheck")
#
# ----------------------------------------------------------------------------
# TASKS:
# ----------------------------------------------------------------------------
@task
@consume_args
def test(args):
"""Execute all tests"""
py_test(args)
# ----------------------------------------------------------------------------
# TASK: test coverage
# ----------------------------------------------------------------------------
@task
# @needs("coverage_collect")
def coverage_report():
"""Generate coverage report from collected coverage data."""
sh("coverage combine")
sh("coverage report")
sh("coverage html")
info("WRITTEN TO: build/coverage.html/")
# -- DISABLED: sh("coverage xml")
@task
@consume_args
def coverage(args):
"""Execute all tests to collect code-coverage data, generate report."""
py_test(args, coverage_module=NAME)
# ----------------------------------------------------------------------------
# TASK: clean
# ----------------------------------------------------------------------------
@task
def clean(options):
"""Cleanup the project workspace."""
for dir_ in options.dirs:
path(dir_).rmtree_s()
for pattern in options.walkdirs_patterns:
dirs = path(".").walkdirs(pattern, errors="ignore")
for dir_ in dirs:
dir_.rmtree()
for file_ in options.files:
path(file_).remove_s()
for pattern in options.walkfiles_patterns:
files = path(".").walkfiles(pattern)
for file_ in files:
file_.remove()
# ----------------------------------------------------------------------------
# UTILS:
# ----------------------------------------------------------------------------
def python(cmdline, cwd="."):
"""Execute a python script by using the current python interpreter."""
return sh("%s %s" % (sys.executable, cmdline), cwd=cwd)
def py_test(args=None, coverage_module=None, opts=""):
"""Execute all tests"""
if not args:
args = ""
if coverage_module:
os.environ["COVERAGE_HOME"] = os.path.abspath(os.getcwd())
opts += " --cov=%s" % coverage_module
sh("py.test {opts} {args}".format(opts=opts, args=args))
def sphinx_build(builder="html", cmdopts=""):
if builder.startswith("-"):
cmdopts += " %s" % builder
builder = ""
sourcedir = options.sphinx.sourcedir
destdir = options.sphinx.destdir
command = "sphinx-build {opts} -b {builder} . {destdir}/{builder}".format(
builder=builder, destdir=destdir, opts=cmdopts)
sh(command, cwd=sourcedir)