-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
93 lines (73 loc) · 2.07 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
# Required executables
ifeq (, $(shell which python))
$(error "No python on PATH.")
endif
POETRY_CMD := python -m poetry
ifeq (, $(shell $(POETRY_CMD)))
$(error "Poetry not available in Python installation.")
endif
export LC_ALL = C
export LANG = C.UTF-8
PY_FILES := my_module tests
VERSION := $(shell poetry version --short)
# Bundle tasks
all: clean venv build
@echo Executed default build pipeline
# Clean up and set up
clean:
@echo Clean project base
find . -type d \
-name ".venv" -o \
-name ".tox" -o \
-name ".ropeproject" -o \
-name ".mypy_cache" -o \
-name ".pytest_cache" -o \
-name "__pycache__" -o \
-iname "*.egg-info" -o \
-name "build" -o \
-name "dist" \
|xargs rm -rfv
clear-cache:
@echo Clear poetry cache
$(POETRY_CMD) cache clear pypi --all --no-interaction
venv: clean
@echo Initialize virtualenv, i.e., install required packages etc.
$(POETRY_CMD) config virtualenvs.in-project true --local
$(POETRY_CMD) install
shell:
@echo Open a new shell using virtualenv
$(POETRY_CMD) shell
# Building software
build: test mypy isort black lint
@echo Run build process to package application
$(POETRY_CMD) build
test:
@echo Run all tests suites
$(POETRY_CMD) run py.test tests
mypy:
@echo Run static code checks against source code base
$(POETRY_CMD) run mypy $(PY_FILES)
isort:
@echo Check for incorrectly sorted imports
$(POETRY_CMD) run isort --check-only $(PY_FILES)
isort-apply:
@echo Check and correct incorrectly sorted imports
$(POETRY_CMD) run isort $(PY_FILES)
black:
@echo Run code formatting using black
$(POETRY_CMD) run black $(PY_FILES)
lint:
@echo Run code formatting checks against source code base
$(POETRY_CMD) run flake8 $(PY_FILES)
outdated:
@echo Show outdated dependencies
$(POETRY_CMD) show --outdated
# Executing
run-venv:
@echo Execute package directly in virtual environment
$(POETRY_CMD) run python -m my_module
install-run:
@echo Install and run package via CLI using the activated Python env
python -m pip install --upgrade .
@echo --- Note: The next command might fail before you reload your shell
my_module_cli