-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
120 lines (92 loc) · 2.28 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
#!/usr/bin/env make
# Change this to be your variant of the python command
PYTHON ?= python # python3 py
# Print out colored action message
MESSAGE = printf "\033[32;01m---> $(1)\033[0m\n"
# path to source files
SRC = ./src
# ---------------------------------------------------------
# Setup a venv and install packages.
#
version:
@printf "Currently using executable: $(PYTHON)\n"
which $(PYTHON)
$(PYTHON) --version
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:
rm -f .coverage *.pyc
rm -rf __pycache__
rm -rf htmlcov
clean-doc:
rm -rf doc
clean-all: clean clean-doc
rm -rf .venv
# ---------------------------------------------------------
# Test all the code at once.
#
pylint:
pylint $(SRC)
flake8:
flake8 $(SRC)
lint: flake8 pylint
unittest:
coverage run -m unittest discover
coverage-report:
coverage report
.PHONY: test
test:
$(MAKE) pylint
$(MAKE) flake8
coverage run -m unittest discover
coverage report
run:
python ./src/main.py
# ---------------------------------------------------------
# Work with generating documentation.
#
.PHONY: pydoc
pydoc:
@$(call MESSAGE,$@)
# This does not work on Windows installed Python
$(PYTHON) -m pydoc -w "$(PWD)"
install -d doc/pydoc
mv *.html doc/pydoc
pdoc:
pdoc -o doc/api $(SRC)
pyreverse:
install -d doc/uml
pyreverse $(SRC)
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 --show-complexity --average $(SRC)
radon-mi:
@$(call MESSAGE,$@)
radon mi --show $(SRC)
radon-raw:
@$(call MESSAGE,$@)
radon raw $(SRC)
radon-hal:
@$(call MESSAGE,$@)
radon hal $(SRC)
metrics: radon-cc radon-mi radon-raw radon-hal