-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-python.mk
101 lines (88 loc) · 3.18 KB
/
make-python.mk
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
# Python standard targets
.PHONY: lint-make
lint-make:
pylint --generate-rcfile > .pylintrc
echo "[pydocstyle]\nignore=" > .pydocstylerc
.PHONY: lint-all
lint-all: lint lint-sec lint-type lint-docstring
.PHONY: lint
lint:
@printf -- "\n\033[33;1m>>> Linting... \033[0m\n"
@for PY_FOLDER in $(PY_FOLDERS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
printf -- "\033[34;1mpylint \033[0m \n"; \
pylint $$PY_FOLDER || echo "failed, continue..."; \
printf -- "\033[34;1mpycodestyle \033[0m \n"; \
pycodestyle --repeat --statistics --count --show-source $$PY_FOLDER || echo "failed, continue..."; \
printf -- "\033[34;1misort \033[0m \n"; \
isort --check-only --diff $$PY_FOLDER || echo "failed, continue..."; \
done
.PHONY: lint-sec
lint-sec:
@printf -- "\n\033[33;1m>>> Linting (security)... \033[0m\n"
@for PY_FOLDER in $(PY_FOLDERS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
printf -- "\033[34;1mbandit \033[0m \n"; \
bandit --recursive -s B101 $$PY_FOLDER || echo "failed, continue..."; \
printf -- "\033[34;1msafety \033[0m \n"; \
safety check || echo "failed, continue..."; \
done
.PHONY: lint-pkg
lint-pkg:
@printf -- "\n\033[33;1m>>> Linting (packaging)... \033[0m\n"
@for PY_FOLDER in $(PY_FOLDERS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
printf -- "\033[34;1mcheck-manifest \033[0m \n"; \
check-manifest -v || echo "failed, continue..."; \
done
.PHONY: lint-type
lint-type:
@printf -- "\n\033[33;1m>>> Linting (mypy)... \033[0m\n"
@for PY_FOLDER in $(PY_FOLDERS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
printf -- "\033[34;1mmypy \033[0m \n"; \
mypy $$PY_FOLDER || echo "failed, continue..."; \
done
.PHONY: lint-docstring
lint-docstring:
@printf -- "\n\033[33;1m>>> Linting (docstrings)... \033[0m\n"
@for PY_FOLDER in $(PY_FOLDERS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
printf -- "\033[34;1mpydocstyle \033[0m \n"; \
pydocstyle --explain --source --count $$PY_FOLDER || echo "failed, continue..."; \
printf -- "\033[34;1mdarglint \033[0m \n"; \
darglint --verbosity 2 --docstring-style numpy --strictness full $$PY_FOLDER || echo "failed, continue..."; \
done
.PHONY: test
test:
@printf -- "\n\033[33;1m>>> Test... \033[0m\n"
@for PY_FOLDER_TEST in $(PY_FOLDERS_TESTS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
pytest $$PY_FOLDER_TEST; \
done
.PHONY: test-v
test-v:
@printf -- "\n\033[33;1m>>> Test... \033[0m\n"
@for PY_FOLDER_TEST in $(PY_FOLDERS_TESTS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
pytest -v $$PY_FOLDER_TEST; \
done
.PHONY: test-vv
test-vv:
@printf -- "\n\033[33;1m>>> Test... \033[0m\n"
@for PY_FOLDER_TEST in $(PY_FOLDERS_TESTS) ; do \
printf -- "\033[36;1m$$PY_FOLDER... \033[0m \n"; \
pytest -vv --capture=no $$PY_FOLDER_TEST; \
done
.PHONY: clear-all
clear-all: clear-pyc clear-build
.PHONY: clear-pyc
clear-pyc:
find . -type d -name '__pycache__' -not -path './venv/*' -exec rm -rf {} +
find . -type f -name '*.py[co]' -not -path './venv/*' -exec rm -f {} +
find . -type f -name '*~' -not -path './venv/*' -exec rm -f {} +
.PHONY: clear-pybuild
clear-pybuild:
rm -fr dist/
rm -fr .eggs/
rm -fr *.egg-info/