This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathMakefile
134 lines (97 loc) · 3.02 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
# Run:
# make help
#
# for a description of the available targets
# ------------------------------------------------------------------------- Help target
TARGET_MAX_CHAR_NUM=20
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
## Show this help message
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
# ------------------------------------------------------------------------ Clean target
## Delete temp operational stuff like artifacts, test outputs etc
clean:
rm -rf .mypy_cache/ .pytest_cache/
rm -f .coverage .coverage.*
rm -rf *.egg-info/ build/ docs/_build/ htmlcov/
# --------------------------------------------------------- Environment related targets
## Create a virtual environment
env:
python3.8 -m venv .venv
source .venv/bin/activate
pip install -U pip
## Install pre-commit hooks
pre-commit:
pip install pre-commit
pre-commit install
## Install package requirements
install:
pip install --no-cache-dir -e ".[full]"
rm -rf *.egg-info/ build/
## Install dev requirements
install-dev:
pip install --no-cache-dir -e ".[test]"
rm -rf *.egg-info/ build/
## Install docs requirements
install-docs:
pip install --no-cache-dir -r docs/requirements.txt
## Bootstrap dev environment
init: pre-commit install install-dev install-docs
# ----------------------------------------------------------------------- Build targets
## Build wheel
build:
python setup.py bdist_wheel
rm -rf .eggs/ build/ *egg-info
## Build source dist
build-sdist:
python setup.py sdist
rm -rf .eggs/ build/ *egg-info
# ---------------------------------------------------------------- Test related targets
PYTEST_ARGS = --show-capture no --verbose --cov finetuner/ --cov-report term-missing --cov-report html
## Run tests
test:
pytest $(PYTEST_ARGS) $(TESTS_PATH)
# ---------------------------------------------------------------- Docs related targets
## Build docs
build-docs:
cd docs/ && bash makedoc.sh development
# ---------------------------------------------------------- Code style related targets
SRC_CODE = finetuner/ tests/
## Run the flake linter
flake:
flake8 $(SRC_CODE)
## Run the black formatter
black:
black $(SRC_CODE)
## Dry run the black formatter
black-check:
black --check $(SRC_CODE)
## Run the isort import formatter
isort:
isort $(SRC_CODE)
## Dry run the isort import formatter
isort-check:
isort --check $(SRC_CODE)
## Run the mypy static type checker
mypy:
mypy $(SRC_CODE)
## Format source code
format: black isort
## Check code style
style: flake black-check isort-check # mypy