-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (73 loc) · 2.05 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
SOURCE_DIR ?= .
TESTS_DIR ?= tests
PYTHON ?= python3
VENV ?= .venv/bin/activate
# Based on https://tech.davis-hansson.com/p/make/
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
.DEFAULT_GOAL := help
.DELETE_ON_ERROR:
# # On Linux and macOS, 'which' can help us find python3.
# # On Windows (with MinGW/MSYS), 'where' is the equivalent.
# ifeq ($(OS),Windows_NT)
# FIND_CMD := where
# REDIRECT := 2> nul
# else
# FIND_CMD := which
# REDIRECT := 2> /dev/null
# endif
# # Locate the python3 executable using system tools.
# DETECTED_PYTHON3 := $(shell $(FIND_CMD) python3 $(REDIRECT))
# When the python3 executable has been located,
# update the PYTHON variable.
ifneq ($(DETECTED_PYTHON3),)
PYTHON := $(DETECTED_PYTHON3)
endif
.PHONY: help
help: ## print help message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: install-deps ## install dependencies
install-deps:
. $(VENV)
$(PYTHON) -m poetry install --no-interaction --no-root
$(PYTHON) -m poetry show
.PHONY: update-deps ## update requirements.txt file from poetry
update-deps:
$(PYTHON) -m poetry update
$(PYTHON) -m poetry export \
--format requirements.txt \
--output requirements.txt \
--without-hashes
.PHONY:
requirements.txt: poetry.lock
$(PYTHON) -m poetry export \
--format requirements.txt \
--output requirements.txt \
--without-hashes
requirements-dev.txt: poetry.lock
$(PYTHON) -m poetry export \
--with dev \
--format requirements.txt \
--output requirements.dev.txt \
--without-hashes
.PHONY: format
format: ## automatically format code to standards
. $(VENV)
ruff check --fix .
isort .
black $(SOURCE_DIR) $(TESTS_DIR)
.PHONY: lint
lint: ## lint code against standards
. $(VENV)
ruff check .
isort . --check --diff
black $(SOURCE_DIR) $(TESTS_DIR) --diff
mypy $(SOURCE_DIR)
.PHONY: test tests
tests: test
test: ## execute unit tests
. $(VENV)
pytest $(TESTS_DIR) --cov $(SOURCE_DIR)