generated from Diapolo10/python-poetry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (45 loc) · 1.76 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
# Inspired by: https://blog.mathieu-leplatre.info/tips-for-your-makefile-with-python.html
PYMODULE := python_ms
TESTS := tests
INSTALL_STAMP := .install.stamp
POETRY := $(shell command -v poetry 2> /dev/null)
MYPY := $(shell command -v mypy 2> /dev/null)
.DEFAULT_GOAL := help
.PHONY: all
all: install lint test
.PHONY: help
help:
@echo "Please use 'make <target>', where <target> is one of"
@echo ""
@echo " install install packages and prepare environment"
@echo " lint run the code linters"
@echo " test run all the tests"
@echo " all install, lint, and test the project"
@echo " clean remove all temporary files listed in .gitignore"
@echo ""
@echo "Check the Makefile to know exactly what each target is doing."
@echo "Most actions are configured in 'pyproject.toml'."
install: $(INSTALL_STAMP)
$(INSTALL_STAMP): pyproject.toml
@if [ -z $(POETRY) ]; then echo "Poetry could not be found. See https://python-poetry.org/docs/"; exit 2; fi
$(POETRY) run pip install --upgrade pip setuptools
$(POETRY) install
touch $(INSTALL_STAMP)
.PHONY: lint
lint: $(INSTALL_STAMP)
# Configured in pyproject.toml
# Skips mypy if not installed
#
# $(POETRY) run isort --profile=black --lines-after-imports=2 --check-only $(TESTS) $(PYMODULE)
# $(POETRY) run black --check $(TESTS) $(PYMODULE) --diff
@if [ -z $(MYPY) ]; then echo "Mypy not found, skipping..."; else echo "Running Mypy..."; $(POETRY) run mypy $(PYMODULE) $(TESTS); fi
@echo "Running Flake8..."; $(POETRY) run pflake8 # This is not a typo
@echo "Running Pylint..."; $(POETRY) run pylint $(PYMODULE)
.PHONY: test
test: $(INSTALL_STAMP)
# Configured in pyproject.toml
$(POETRY) run pytest
.PHONY: clean
clean:
# Delete all files in .gitignore
git clean -Xdf