-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
85 lines (72 loc) · 2.54 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
# Usage:
# make # Runs copyright-update and flake test
# make build # to build the package
# make copyright # to build the package
#
# Set NO_VENV=True like this 'make NO_VENV=True build' to skip virtualenv activation for python commands
VIRTUAL_ENV_PATH=venv
SKIP_VENV="${NO_VENV}"
SETUP_MODULE=setup.py
.DEFAULT_GOAL := pre_commit
pre_commit: copyright format flake8
help:
@echo "Usage:"
@echo " make - Run this before each commit. It runs all required pre-commit actions"
@echo " make copyright - Updates copyright preamble for each file"
@echo " make flake8 - Runs codestyle checks"
@echo " make test - Runs unit tests"
@echo " make build - Builds distribution package"
@echo " make clean - Removes temporary files, artifacts, etc"
@echo ""
@echo "Notes:"
@echo "Set NO_VENV=True like this 'make NO_VENV=True build' to skip virtualenv activation for python commands"
copyright:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Applying copyright..."; \
./development/copyright-update; \
echo "DONE: copyright"; \
)
flake8:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing Flake8 checks..."; \
./development/flake8; \
echo "DONE: Flake8"; \
)
test:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing unit tests..."; \
pytest; \
echo "DONE: Unit tests"; \
)
build: copyright flake8 clean
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Building wheel package..."; \
bash -c "cd src && python ./$(SETUP_MODULE) bdist_wheel --dist-dir=../dist --bdist-dir=../../build"; \
echo "DONE: wheel package"; \
)
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Building source distribution..."; \
bash -c "cd src && python ./$(SETUP_MODULE) sdist --dist-dir=../dist"; \
echo "DONE: source distribution"; \
)
clean:
rm -rf src/build dist/* *.egg-info src/*.egg-info .pytest_cache
format:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing Black code formater..."; \
black ./src; \
echo "DONE: Black"; \
)
check-format:
@( \
if [ -z $(SKIP_VENV) ]; then source $(VIRTUAL_ENV_PATH)/bin/activate; fi; \
echo "Runing Black code formater..."; \
black --check ./src; \
echo "DONE: Black"; \
)