forked from robbert-harms/pyschematron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
161 lines (135 loc) · 4.66 KB
/
Makefile
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
SHELL := /bin/bash
PYTHON := $$(which python3)
PIP := $$(which pip3)
PYTEST := $$(which pytest)
PROJECT_NAME := pyschematron
GIT_BRANCH := $$(git branch --show-current)
PROJECT_VERSION := $(shell grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
.PHONY: help
help:
@echo "clean: remove all build, test, coverage and Python artifacts (no uninstall)"
@echo "test(s): run unit and integration tests with the default Python."
@echo "test-unit: run the unit tests using the default Python."
@echo "test-integration: run the integration tests using the default Python."
@echo "test-all: run all tests using all environments using tox"
@echo "docs: generate Sphinx HTML documentation, including API docs"
@echo "docs-pdf: generate the PDF documentation, including API docs"
@echo "docs-man: generate the linux manpages"
@echo "docs-changelog: generate the changelog documentation"
@echo "install-deps: install all the dependencies"
@echo "install-symlink: install the package as a symlink, to allow continuous development"
@echo "uninstall: uninstall PySchematron (while keeping the dependencies)"
@echo "prepare-release: prepare for a new release"
@echo "release: package and release the new version"
.PHONY: clean
clean: clean-build clean-pyc clean-test
.PHONY: clean-build
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
.PHONY: clean-pyc
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
.PHONY: clean-test
clean-test:
rm -rf .tox/
rm -f .coverage
rm -rf htmlcov/
rm -rf .pytest_cache
rm -rf tests/htmlcov
rm -rf tests/.coverage
find tests -name 'build' -exec rm -rf {} +
find tests -name '.coverage' -exec rm -rf {} +
.PHONY: tests
tests: test
.PHONY: test
test:
mkdir -p build
COVERAGE_FILE=build/.coverage \
$(PYTEST) tests --cov=$(PROJECT_NAME) --cov-report=html:build/coverage/defaultenv --cov-report=term --html=build/pytest/report-defaultenv.html --self-contained-html
.PHONY: test-unit
test-unit:
mkdir -p build
COVERAGE_FILE=build/.coverage \
$(PYTEST) tests/unit --cov=$(PROJECT_NAME) --cov-report=html:build/coverage/defaultenv --cov-report=term --html=build/pytest/report-defaultenv.html --self-contained-html
.PHONY: test-integration
test-integration:
mkdir -p build
COVERAGE_FILE=build/.coverage \
$(PYTEST) tests/integration --cov=$(PROJECT_NAME) --cov-report=html:build/coverage/defaultenv --cov-report=term --html=build/pytest/report-defaultenv.html --self-contained-html
.PHONY: test-all
test-all:
tox
.PHONY: docs
docs:
mkdir -p build
rm -f docs/$(PROJECT_NAME)*.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean
sphinx-apidoc -o docs/ $(PROJECT_NAME)
$(MAKE) -C docs html SPHINXBUILD='python3 $(shell which sphinx-build)'
@echo "To view results type: firefox docs/_build/html/index.html &"
.PHONY: docs-pdf
docs-pdf:
mkdir -p build
rm -f docs/$(PROJECT_NAME)*.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean
sphinx-apidoc -o docs/ $(PROJECT_NAME)
$(MAKE) -C docs latexpdf SPHINXBUILD='python3 $(shell which sphinx-build)'
@echo "To view results use something like: evince docs/_build/latex/$(PROJECT_NAME).pdf &"
.PHONY: docs-man
docs-man:
rm -f docs/$(PROJECT_NAME)*.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean
sphinx-apidoc -o docs/ $(PROJECT_NAME)
$(MAKE) -C docs man SPHINXBUILD='python3 $(shell which sphinx-build)'
@echo "To view results use something like: man docs/_build/man/$(PROJECT_NAME).1 &"
.PHONY: docs-changelog
docs-changelog:
gitchangelog
.PHONY: prepare-release
prepare-release: clean
@echo "Current version: "$(PROJECT_VERSION)
@while [ -z "$$NEW_VERSION" ]; do \
read -r -p "Give new version: " NEW_VERSION;\
done && \
( \
printf 'Setting new version: %s \n\n' \
"$$NEW_VERSION " \
) && sed -i 's/version = \"\(.*\)\"/version = "'$$NEW_VERSION'"/g' pyproject.toml
$(MAKE) docs-changelog
@echo "Consider manually inspecting CHANGELOG.rst for possible improvements."
.PHONY: release
release: clean release-git release-pip
.PHONY: release-git
release-git:
git add -u
git diff-index --quiet HEAD || git commit -am "New release"
git push
git tag -a v$(PROJECT_VERSION) -m "Version $(PROJECT_VERSION)"
git push origin --tags
.PHONY: release-pip
release-pip:
flit publish
.PHONY: dist
dist: clean
$(PYTHON) setup.py sdist
$(PYTHON) setup.py bdist_wheel
ls -l dist
.PHONY: install-deps
install-deps:
flit install --only-deps
.PHONY: install-symlink
install-symlink:
flit install --symlink
.PHONY: uninstall
uninstall:
$(PIP) uninstall -y $(PROJECT_NAME)