-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
214 lines (128 loc) · 4.71 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# Sorry that this Makefile is a bit of a disaster. Run `make help` to
# see a list of valid targets.
PYTHON ?= $(shell which python3 python 2>/dev/null | head -n1)
PYTHON := $(PYTHON)
TOX ?= $(shell which tox 2>/dev/null | head -n1)
TOX := $(TOX)
PROJECT := $(shell $(PYTHON) ./setup.py --name)
VERSION := $(shell $(PYTHON) ./setup.py --version)
ARCHIVE := $(PROJECT)-$(VERSION).tar.gz
# for hosting local docs preview
PORT ?= 8900
define checkfor
@if ! which $(1) >/dev/null 2>&1 ; then \
echo $(1) "is required, but not available" 1>&2 ; \
exit 1 ; \
fi
endef
##@ Basic Targets
default: quick-test ## Runs the quick-test target
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
report-python:
@echo "Using python" $(PYTHON)
@$(PYTHON) -VV
##@ Local Build and Install
build: clean-built report-python flake8 ## Produces a wheel using the default system python
@$(TOX) -qe build
install: build ## Installs using the default python for the current user
ifeq ($(UID),"0")
@$(PYTHON) -B -m pip.__main__ \
install -IU --no-deps \
dist/$(PROJECT)-$(VERSION)-py3-none-any.whl
else
$(PYTHON) -B -m pip.__main__ \
install -IU --no-deps --user \
dist/$(PROJECT)-$(VERSION)-py3-none-any.whl
@mkdir -p ~/.koji/plugins
@rm -f ~/.koji/plugins/kojismokydingometa.py
@cp -v koji_cli_plugins/kojismokydingometa.py ~/.koji/plugins/
endif
uninstall: ## Uninstalls using the default python for the current user
ifeq ($(UID),"0")
@$(PYTHON) -B -m pip.__main__ \
uninstall $(PROJECT)
else
@rm -f ~/.koji/plugins/kojismokydingometa.py
@$(PYTHON) -B -m pip.__main__ \
uninstall $(PROJECT)
endif
##@ Cleanup
purge: clean
@rm -rf .eggs .tox .mypy_cache
tidy: ## Removes stray eggs and .pyc files
@rm -rf *.egg-info
@$(call checkfor,find)
@find -H . \
\( -iname '.tox' -o -iname '.eggs' -prune \) -o \
\( -type d -iname '__pycache__' -exec rm -rf {} + \) -o \
\( -type f -iname '*.pyc' -exec rm -f {} + \)
clean-built:
@rm -rf build/* dist/*
@if [ -f ./"$(ARCHIVE)" ] ; then rm -f ./"$(ARCHIVE)" ; fi
clean: clean-built tidy ## Removes built content, test logs, coverage reports
@rm -rf .coverage* bandit.sarif htmlcov/* logs/*
##@ Containerized RPMs
packaging-build: $(ARCHIVE) ## Launches all containerized builds
@./tools/launch-build.sh
packaging-test: packaging-build ## Launches all containerized tests
@rm -rf logs/*
@./tools/launch-test.sh
##@ Testing
test: clean requires-tox ## Launches tox
@$(TOX) -q
bandit: requires-tox ## Launches bandit via tox
@$(TOX) -qe bandit
flake8: requires-tox ## Launches flake8 via tox
@$(TOX) -qe flake8
mypy: requires-tox ## Launches mypy via tox
@$(TOX) -qe mypy
coverage: requires-tox ## Collects coverage report
@$(TOX) -qe coverage
quick-test: requires-tox flake8 ## Launches nosetest using the default python
@$(TOX) -qe quicktest
koji-git: requires-tox flake8 ## Launches nosetest with koji installed from git
@$(TOX) -qe koji-git
##@ RPMs
srpm: $(ARCHIVE) ## Produce an SRPM from the archive
@$(call checkfor,rpmbuild)
@rpmbuild \
--define "_srcrpmdir dist" \
--define "dist %{nil}" \
-ts "$(ARCHIVE)"
rpm: $(ARCHIVE) ## Produce an RPM from the archive
@$(call checkfor,rpmbuild)
@rpmbuild --define "_rpmdir dist" -tb "$(ARCHIVE)"
archive: $(ARCHIVE) ## Extracts an archive from the current git commit
$(ARCHIVE): requires-git
@git archive HEAD --prefix "$(PROJECT)-$(VERSION)/" \
--format tar.gz -o $@
##@ Documentation
docs: clean-docs requires-tox docs/overview.rst ## Build sphinx docs
@$(TOX) -qe sphinx
overview: docs/overview.rst ## rebuilds the overview from README.md
docs/overview.rst: README.md
@$(call checkfor,pandoc)
@pandoc --from=markdown --to=rst -o $@ $<
clean-docs: ## Remove built docs
@rm -rf build/sphinx
preview-docs: docs ## Build and hosts docs locally
@$(PYTHON) -B -m http.server -d build/sphinx \
-b 127.0.0.1 $(PORT)
##@ Workflow Features
project: ## project name
@echo $(PROJECT)
version: ## project version
@echo $(VERSION)
python: ## detected python executable
@echo $(PYTHON)
release-notes: ## markdown variation of current version release notes
@$(call checkfor,pandoc)
@pandoc --from=rst --to=markdown -o - \
docs/release_notes/v$(VERSION).rst
requires-git:
@$(call checkfor,git)
requires-tox:
@$(call checkfor,$(TOX))
.PHONY: archive build clean clean-built clean-docs default deploy-docs docs flake8 help koji-git mypy overview packaging-build packaging-test project python quick-test release-notes report-python requires-git requires-tox rpm srpm stage-docs test tidy version
# The end.