-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
69 lines (57 loc) · 1.66 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
.PHONY = help build install clean test lint freeze fix
PYTHON = python3
.DEFAULT: help
help:
@echo "make build"
@echo " generate protobuf related files"
@echo "make install "
@echo " install the library"
@echo "make test"
@echo " run tests"
@echo "make lint"
@echo " run pylint and mypy"
@echo "make clean"
@echo " clean cache files"
@echo "make freeze"
@echo " generate requirements"
@echo "make fix"
@echo " run yapf to format all .py files"
@echo "make all"
@echo " run make fix, make test, and make lint"
build:
@echo "\033[0;32mGenerate protobuf message\033[0m"
protoc -I=banditpylib --python_out=banditpylib banditpylib/data.proto --mypy_out=banditpylib
install_requirements:
pip install --upgrade pip
pip install -r requirements.txt
install: install_requirements
pip install -e .
test:
@echo "\033[0;32mRun tests\033[0m"
${PYTHON} -m pytest -s banditpylib
lint:
@echo "\033[0;32mCheck static errors\033[0m"
${PYTHON} -m pylint --jobs=8 banditpylib
@echo "\033[0;32mCheck static typing errors\033[0m"
${PYTHON} -m mypy banditpylib
clean-pyc:
@echo "\033[0;32mClean cache files\033[0m"
find . -name '*.pyc' -delete
find . -name '*.pyo' -delete
find . -name '*~' -delete
find . -name '__pycache__' -type d | xargs rm -fr
find . -name '.pytest_cache' -type d | xargs rm -fr
find . -name '.ipynb_checkpoints' -type d | xargs rm -fr
rm -rf .mypy_cache
clean: clean-pyc
freeze:
python3 -m pip freeze > requirements.txt
fix:
@echo "\033[0;32mFormat code\033[0m"
yapf -irp --style="{indent_width: 2}" --exclude 'banditpylib/data_pb2.py' banditpylib
all:
make fix
@echo ""
make test
@echo ""
make lint