11.DEFAULT_GOAL := help
2+ .PHONY : check check-code-quality check-docs check-types clean docs-cp docs docs-serve docs-deploy help format setup test
23
34PY_SRC := lumapps/
45CI ?= false
56TESTING ?= false
7+ PYTHON ?= python3.7
8+ PIP = .venv/bin/pip
9+ POETRY ?= .venv/bin/poetry
610
7- .PHONY : check
811check : check-docs check-code-quality check-types # # Check it all!
912
10- .PHONY : check-code-quality
1113check-code-quality : # # Check the code quality.
12- @poetry run failprint -t " Checking code quality" -- flake8 --config=config/flake8.ini $(PY_SRC )
14+ @$( POETRY ) run failprint -t " Checking code quality" -- flake8 --config=config/flake8.ini $(PY_SRC )
1315
14-
15- .PHONY : check-docs
1616check-docs : # # Check if the documentation builds correctly.
17- @poetry run failprint -t " Building documentation" -- mkdocs build -s
17+ @$( POETRY ) run failprint -t " Building documentation" -- mkdocs build -s
1818
19- .PHONY : check-types
2019check-types : # # Check that the code is correctly typed.
21- @poetry run failprint -t " Type-checking" -- mypy --config-file config/mypy.ini $(PY_SRC )
20+ @$( POETRY ) run failprint -t " Type-checking" -- mypy --config-file config/mypy.ini $(PY_SRC )
2221
23- .PHONY : clean
2422clean : # # Delete temporary files.
2523 @rm -rf build 2> /dev/null
2624 @rm -rf .coverage* 2> /dev/null
@@ -33,54 +31,37 @@ clean: ## Delete temporary files.
3331 @rm -rf tests/__pycache__ 2> /dev/null
3432 @find . -name " *.rej" -delete 2> /dev/null
3533
36- .PHONY : docs-cp
3734docs-cp :
3835 cp README.md docs/index.md
3936 cp LICENSE.md docs/
4037
41- .PHONY : docs
4238docs : docs-cp # # Build the documentation locally.
43- @poetry run mkdocs build
39+ @$( POETRY ) run mkdocs build
4440
45- .PHONY : docs-serve
4641docs-serve : docs-cp # # Serve the documentation (localhost:8000).
47- @poetry run mkdocs serve
42+ @$( POETRY ) run mkdocs serve
4843
49- .PHONY : docs-deploy
5044docs-deploy : docs-cp # # Deploy the documentation on GitHub pages.
51- @poetry run mkdocs gh-deploy
45+ @$( POETRY ) run mkdocs gh-deploy
5246
53- .PHONY : help
5447help : # # Print this help.
5548 @awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST ) | sort
5649
57- .PHONY : format
5850format : # # Run formatting tools on the code.
59- @poetry run failprint -t " Formatting code" -- black $(PY_SRC )
60- @poetry run failprint -t " Ordering imports" -- isort -y -rc $(PY_SRC )
61-
51+ @$(POETRY ) run failprint -t " Formatting code" -- black $(PY_SRC )
52+ @$(POETRY ) run failprint -t " Ordering imports" -- isort -y -rc $(PY_SRC )
6253
63- .PHONY : setup
64- setup : # # Setup the development environment (install dependencies).
65- @if ! $(CI ) ; then \
66- if ! command -v pipx & > /dev/null; then \
67- pip install pipx; \
68- fi ; \
69- if ! command -v poetry & > /dev/null; then \
70- pipx install poetry; \
71- fi ; \
72- fi ; \
73- poetry config virtualenvs.in-project true
74- poetry install -v
75- @if ! $(CI ) ; then \
76- poetry run pre-commit install; \
77- poetry run pre-commit install --hook-type commit-msg; \
78- fi ; \
54+ setup : .venv # # Setup the development environment (install dependencies).
55+ $(POETRY ) config virtualenvs.in-project true
56+ $(POETRY ) install -v
57+ $(POETRY ) run pre-commit install
58+ $(POETRY ) run pre-commit install --hook-type commit-msg
7959
80-
81- .PHONY : test
8260test : # # Run the test suite and report coverage. 2>/dev/null
83- @poetry run pytest -c config/pytest.ini
84- @poetry run coverage html --rcfile=config/coverage.ini
85-
61+ @$(POETRY ) run pytest -c config/pytest.ini
62+ @$(POETRY ) run coverage html --rcfile=config/coverage.ini
8663
64+ .venv : # # Install the virtual env directory
65+ $(PYTHON ) -m venv .venv
66+ $(PIP ) install --quiet --upgrade pip
67+ $(PIP ) install poetry
0 commit comments