forked from claws/cookiecutter-python-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
187 lines (135 loc) · 4.07 KB
/
Makefile
File metadata and controls
187 lines (135 loc) · 4.07 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
# This makefile has been created to help developers perform common actions.
MAKEFLAGS += --no-print-directory
ifeq ($(OS),Windows_NT)
UNAME_S := Windows
else
UNAME_S := $(shell uname -s)
endif
# Set GIT variable based on the operating system
ifeq ($(UNAME_S), Linux)
GIT := $(shell command -v git)
endif
ifeq ($(UNAME_S), Darwin)
GIT := $(shell command -v git)
endif
ifeq ($(UNAME_S), Windows)
GIT := $(shell where git)
endif
define CHECK_GIT
$(if $(GIT),,$(error "git command not available."))
$(if $(wildcard .git),,$(error "Not a git repository."))
endef
# Do not remove this block. It is used by the 'help' rule when
# constructing the help output.
# help:
# help: {{cookiecutter.package_display_name}} Makefile help
# help:
# help: help - display makefile help information
.PHONY: help
ifeq ($(UNAME_S), Windows)
help:
@powershell -File scripts/generate_help.ps1 -MakefilePath Makefile
else
help:
@grep "^#\shelp:" Makefile | \
grep -v grep | \
sed 's/\# help\: //' | \
sed 's/\# help\://'
endif
# help: venv - enter a dev virtual environment
.PHONY: venv
venv:
@hatch shell
# help: clean - clean all files using .gitignore rules
.PHONY: clean
clean:
$(call CHECK_GIT)
@$(GIT) clean -X -f -d
# help: scrub - clean all files, even untracked files
.PHONY: scrub
scrub:
$(call CHECK_GIT)
@$(GIT) clean -x -f -d
# help: test - run tests
.PHONY: test
test:
@hatch test --all --cover
# help: test-verbose - run tests [verbosely]
.PHONY: test-verbose
test-verbose:
@hatch test -v --all --cover
# help: coverage - perform test coverage checks
.PHONY: coverage
coverage:
@hatch run coverage:run-new-reports
# help: format - perform code style format
.PHONY: format
format:
@hatch run style:run-black
# help: check-format - check code format compliance
.PHONY: check-format
check-format:
@hatch run style:run-black-check
@hatch run style:run-flake8
# help: sort-imports - apply import sort ordering
.PHONY: sort-imports
sort-imports:
@hatch run style:run-isort
# help: check-sort-imports - check imports are sorted
.PHONY: check-sort-imports
check-sort-imports:
@hatch run style:run-isort-check
# help: style - perform code style format
.PHONY: style
style: sort-imports format
# help: check-style - check code style compliance
.PHONY: check-style
check-style: check-sort-imports check-format
# help: check-types - check type hint annotations
.PHONY: check-types
check-types:
@hatch run types:check
# help: check-lint - run static analysis checks
.PHONY: check-lint
check-lint:
@hatch run lint:check
# help: check-static-analysis - check code style compliance
.PHONY: check-static-analysis
check-static-analysis: check-lint check-types
# help: docs - generate project documentation
.PHONY: docs
docs: coverage
@hatch run docs:build
# help: check-docs - quick check docs consistency
.PHONY: check-docs
check-docs:
@hatch run docs:build-dummy
# help: serve-docs - serve project html documentation
.PHONY: serve-docs
serve-docs:
@hatch run python -m http.server -b 127.0.0.1 -d docs/build/html
# help: dist - create a wheel distribution package
.PHONY: dist
dist:
@hatch build
# help: dist-test - test a wheel distribution package
.PHONY: dist-test
ifeq ($(UNAME_S), Windows)
dist-test: dist
@cd dist && \
@powershell \
-File ../tests/test-dist.ps1 \
./{{cookiecutter.package_name}}-*-py3-none-any.whl
else
dist-test: dist
@cd dist && \
../tests/test-dist.bash \
./{{cookiecutter.package_name}}-*-py3-none-any.whl
endif
# help: dist-upload - upload a wheel distribution package
.PHONY: dist-upload
dist-upload:
@hatch publish
# Keep these lines at the end of the file to retain nice help
# output formatting.
# help: