-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
181 lines (136 loc) · 3.93 KB
/
Makefile
File metadata and controls
181 lines (136 loc) · 3.93 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
.DEFAULT_GOAL := help
today := $(shell date +%F)
nextversion := void
versiontype := void
define LEAD_AUTHORS
Lead developers:
David R. Smith
Kevin Tritz
Howard Yuh
endef
export LEAD_AUTHORS
define FDF_SHORTLOG
Commits from obsolete FDF repository:
261 David R. Smith
41 Kevin Tritz
17 ktritz
10 Howard Yuh
7 John Schmitt
4 hyyuh
2 jcschmitt
endef
export FDF_SHORTLOG
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
from urllib import pathname2url
except:
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"
.PHONY: help
help: ## show this help message
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
.PHONY: docs
docs: docs-pdf docs-html ## build HTML and PDF documents
.PHONY: docs-html
docs-html: ## build HTML documents
$(MAKE) -C docs/ html
#@$(BROWSER) docs/build/html/index.html
.PHONY: docs-pdf
docs-pdf: ## build PDF documents
$(MAKE) -C docs/ latexpdf
.PHONY: outdated
outdated: # list outdated conda and pip packages
@echo "outdated conda packages"
@conda update --dry-run --all
@echo "outdated pip packages (may be managed by conda)"
@pip list --outdated
.PHONY: test
test: ## run pytest in current Python environment
pytest test/
.PHONY: coverage
coverage: ## check test coverage and show report in terminal
@rm -f .coverage
coverage run --module pytest
coverage report
.PHONY: coverage-html
coverage-html: coverage ## check test coverage and show report in browser
@rm -fr htmlcov/
@coverage html
@$(BROWSER) htmlcov/index.html
.PHONY: lint
lint: ## run flake8 for code quality review
@rm -f flake8.output.txt
flake8 --exit-zero fdp/
.PHONY: autopep
autopep: ## run autopep8 to fix minor pep8 violations
autopep8 --in-place -r fdp/
autopep8 --in-place -r test/
.PHONY: authors
authors: ## update AUTHORS.txt
@rm -f AUTHORS.txt
@printf "%s\n" \
"$$LEAD_AUTHORS" \
"" \
"Commits from authors:" > AUTHORS.txt
@git shortlog -s -n >> AUTHORS.txt
@printf "%s\n" \
"" \
"$$FDF_SHORTLOG" >> AUTHORS.txt
.PHONY: changelog
changelog: ## internal use only
$(eval nextversion := $(shell bumpversion \
--no-commit --no-tag --dry-run --list --allow-dirty $(versiontype) | \
grep "^new_version=.*$$" | \
grep -o "[0-9]*\.[0-9]*\.[0-9]*$$"))
@cp -f CHANGELOG.rst tmp.rst
@rm -f CHANGELOG.rst
@printf '%s\n' \
"Release v$(nextversion) -- $(today)" \
"=========================================" \
"" \
"::" \
"" > CHANGELOG.rst
@git log --format=" %h %s" \
`git describe --tags --abbrev=0`..HEAD \
>> CHANGELOG.rst
@printf '%s\n' "" >> CHANGELOG.rst
@cat tmp.rst >> CHANGELOG.rst
@rm -f tmp.rst
.PHONY: bumpversion
bumpversion: authors changelog ## internal use only
@git add CHANGELOG.rst AUTHORS.txt
@git commit -m "updated CHANGELOG.rst and AUTHORS.txt"
@bumpversion $(versiontype) # runs 'git commit'
.PHONY: bump-major
bump-major: versiontype = major
bump-major: bumpversion ## update AUTHORS and CHANGELOG; bump major version and commit
.PHONY: bump-minor
bump-minor: versiontype = minor
bump-minor: bumpversion ## update AUTHORS and CHANGELOG; bump minor version and commit
.PHONY: bump-patch
bump-patch: versiontype = patch
bump-patch: bumpversion ## update AUTHORS and CHANGELOG; bump patch version and commit
.PHONY: clean
clean: clean-pyc clean-docs ## remove all build, docs, and Python artifacts
.PHONY: clean-docs
clean-docs: ## remove docs/build
rm -rf docs/build
.PHONY: clean-pyc
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +