-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfabfile.py
98 lines (74 loc) · 2.37 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
91
92
93
94
95
96
97
98
from fabric.api import local, lcd
# Default choice for Python executable
PYTHON = "python"
COVERAGE = "coverage"
# Paths for mpfr and gmp libraries and include files.
LIBRARY_PATH = "/opt/local/lib"
INCLUDE_PATH = "/opt/local/include"
def build(python=PYTHON):
"""Build the bigfloat library for in-place testing."""
clean()
local(
"LIBRARY_PATH={library_path} CPATH={include_path} {python} "
"setup.py build_ext --inplace".format(
library_path=LIBRARY_PATH,
include_path=INCLUDE_PATH,
python=python,
)
)
def install(python=PYTHON):
"""Install into site-packages"""
local(
"LIBRARY_PATH={library_path} CPATH={include_path} {python} "
"setup.py build".format(
library_path=LIBRARY_PATH,
include_path=INCLUDE_PATH,
python=python,
)
)
local("sudo {python} setup.py install".format(python=python))
def uninstall(python=PYTHON):
"""Uninstall from site-packages"""
site_packages = local(
"{python} -c 'from distutils.sysconfig import "
"get_python_lib; print(get_python_lib())'".format(python=python),
capture=True,
)
with lcd(site_packages):
local("sudo rm mpfr.so")
local("sudo rm -fr bigfloat")
local("sudo rm bigfloat*.egg-info")
def clean():
"""Remove build artifacts."""
local("git clean -fdX")
def run_tests(python=PYTHON):
unittest = "{python} -m unittest".format(python=python)
local("{unittest} discover -v .".format(unittest=unittest))
def test(python=PYTHON):
"""Run tests on a single version of Python."""
build(python=python)
run_tests(python=python)
def coverage(coverage=COVERAGE):
local("{coverage} run -m unittest discover -v .".format(coverage=coverage))
local("{coverage} html".format(coverage=coverage))
def html():
"""Build html documentation."""
clean()
with lcd("docs"):
local("make html")
def pdf():
"""Build PDF documentation."""
clean()
with lcd("docs"):
local("make latexpdf")
def docs(python=PYTHON):
"""Build PDF and html documentation."""
html()
pdf()
def test_all():
"""Run tests on Python versions 2.7 and 3.5 through 3.8."""
test(python="python2.7")
test(python="python3.5")
test(python="python3.6")
test(python="python3.7")
test(python="python3.8")