-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
152 lines (114 loc) · 2.89 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
#!/usr/bin/env make
# Change this to be your variant of the python command
# Set the env variable PYTHON to another value if needed
# PYTHON=python3 make version
PYTHON ?= python # python3 py
# Print out colored action message
MESSAGE = printf "\033[32;01m---> $(1)\033[0m\n"
all:
# ---------------------------------------------------------
# Check the current python executable.
#
version:
@printf "Currently using executable: $(PYTHON)\n"
which $(PYTHON)
$(PYTHON) --version
# ---------------------------------------------------------
# Setup a venv and install packages.
#
venv:
[ -d .venv ] || $(PYTHON) -m venv .venv
@printf "Now activate the Python virtual environment.\n"
@printf "On Unix and Mac, do:\n"
@printf ". .venv/bin/activate\n"
@printf "On Windows (bash terminal), do:\n"
@printf ". .venv/Scripts/activate\n"
@printf "Type 'deactivate' to deactivate.\n"
install:
$(PYTHON) -m pip install -r requirements.txt
installed:
$(PYTHON) -m pip list
# ---------------------------------------------------------
# Cleanup generated and installed files.
#
clean:
@$(call MESSAGE,$@)
rm -f .coverage *.pyc
rm -rf __pycache__
rm -rf htmlcov
clean-doc: clean
@$(call MESSA E,$@)
rm -rf doc
clean-all: clean clean-doc
@$(call MESSAGE,$@)
rm -rf .venv
# ---------------------------------------------------------
# Work with static code linters.
#
pylint:
@$(call MESSAGE,$@)
-cd war && $(PYTHON) -m pylint *.py
flake8:
@$(call MESSAGE,$@)
-flake8
lint: flake8 pylint
# ---------------------------------------------------------
# Work with codestyle.
#
black:
@$(call MESSAGE,$@)
$(PYTHON) -m black war/ test/
codestyle: black
# ---------------------------------------------------------
# Work with unit test and code coverage.
#
unittest:
@$(call MESSAGE,$@)
$(PYTHON) -m unittest discover
coverage:
@$(call MESSAGE,$@)
coverage run -m unittest discover
coverage html
coverage report -m
test: lint coverage
# ---------------------------------------------------------
# Work with generating documentation.
#
.PHONY: pydoc
pydoc:
@$(call MESSAGE,$@)
install -d doc/api
$(PYTHON) -m pydoc -w war/*.py
mv *.html doc/pydoc
pdoc:
@$(call MESSAGE,$@)
pdoc --force --html --output-dir doc/api war/*.py
pyreverse:
@$(call MESSAGE,$@)
install -d doc/uml
pyreverse war/*.py
dot -Tpng classes.dot -o doc/uml/classes.png
dot -Tpng packages.dot -o doc/uml/packages.png
rm -f classes.dot packages.dot
doc: pdoc pyreverse #pydoc sphinx
# ---------------------------------------------------------
# Calculate software metrics for your project.
#
radon-cc:
@$(call MESSAGE,$@)
radon cc . -a
radon-mi:
@$(call MESSAGE,$@)
radon mi .
radon-raw:
@$(call MESSAGE,$@)
radon raw .
radon-hal:
@$(call MESSAGE,$@)
radon hal .
metrics: radon-cc radon-mi radon-raw radon-hal
# ---------------------------------------------------------
# Find security issues in your project.
#
bandit:
bandit -r .