Skip to content

Commit e354b27

Browse files
committed
Prettify make output commentary
1 parent 8a456d7 commit e354b27

File tree

1 file changed

+93
-40
lines changed

1 file changed

+93
-40
lines changed

Makefile

Lines changed: 93 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,107 @@
1-
.PHONY: install
2-
install: ## Install the virtual environment and install the pre-commit hooks
3-
@echo "🚀 Creating virtual environment using uv"
4-
@uv sync
5-
@uv run pre-commit install
1+
.DELETE_ON_ERROR:
2+
.PHONY: FORCE
3+
.PRECIOUS:
4+
.SUFFIXES:
65

7-
.PHONY: check
8-
check: ## Run code quality tools.
9-
@echo "🚀 Checking lock file consistency with 'pyproject.toml'"
10-
@uv lock --locked
11-
@echo "🚀 Linting code: Running pre-commit"
12-
@uv run pre-commit run -a
13-
#@echo "🚀 Static type checking: Running ty"
14-
#@uv run ty check
15-
@echo "🚀 Checking for obsolete dependencies: Running deptry"
16-
@uv run deptry src
6+
.DEFAULT_GOAL := help
7+
default: help
178

18-
.PHONY: test
19-
test: ## Test the code with pytest
20-
@echo "🚀 Testing code: Running pytest"
21-
@uv run python -m pytest # --cov --cov-config=pyproject.toml --cov-report=xml
9+
SHELL:=/bin/bash
2210

23-
.PHONY: build
24-
build: clean-build ## Build wheel file
25-
@echo "🚀 Creating wheel file"
26-
@uvx --from build pyproject-build --installer uv
11+
COLOR_RESET=\033[0m
12+
COLOR_CYAN_BOLD=\033[1;36m
13+
define ECHO_BANNER
14+
@echo -e "⏩$(COLOR_CYAN_BOLD)$(1)$(COLOR_RESET)"
15+
endef
16+
17+
############################################################################
18+
#= BASIC USAGE
2719

28-
.PHONY: clean-build
29-
clean-build: ## Clean build artifacts
30-
@echo "🚀 Removing build artifacts"
31-
@uv run python -c "import shutil; import os; shutil.rmtree('dist') if os.path.exists('dist') else None"
20+
.PHONY: help
21+
help: ## Display help message
22+
@uvx python -c "import re; \
23+
[[print(f'- \033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([\sa-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]" | sort
24+
25+
26+
############################################################################
27+
#= SETUP, INSTALLATION, PACKAGING
28+
29+
install: devready
30+
.PHONY: devready
31+
devready: ## Prepare local dev env: Create virtual env, install the pre-commit hooks
32+
$(call ECHO_BANNER, "Prepare local dev env: Create virtual env, install the pre-commit hooks")
33+
uv sync --dev
34+
uvx pre-commit install
35+
36+
.PHONY: build
37+
build: ## Build package
38+
$(call ECHO_BANNER, "Building package")
39+
rm -fr dist
40+
uvx --from build pyproject-build --installer uv
3241

3342
.PHONY: publish
3443
publish: ## Publish a release to PyPI.
35-
@echo "🚀 Publishing."
36-
@uvx twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
44+
$(call ECHO_BANNER, "Publishing to PyPI.")
45+
uvx publish
46+
3747

38-
.PHONY: build-and-publish
39-
build-and-publish: build publish ## Build and publish.
48+
############################################################################
49+
#= TESTING AND CODE QUALITY
50+
51+
.PHONY: check
52+
cqa check: ## Run code quality tools.
53+
$(call ECHO_BANNER, "Checking lock file consistency with 'pyproject.toml'")
54+
uv lock --locked
55+
$(call ECHO_BANNER, "Linting code: Running pre-commit")
56+
uvx pre-commit run -a
57+
$(call ECHO_BANNER, "Checking for obsolete dependencies: Running deptry")
58+
uvx deptry src
59+
60+
.PHONY: test
61+
test: ## Test the code with pytest
62+
@echo "🚀 Testing code: Running pytest"
63+
pytest
64+
#uvx python -m pytest # --cov --cov-config=pyproject.toml --cov-report=xml
65+
66+
67+
############################################################################
68+
#= DOCUMENTATION
4069

4170
.PHONY: docs-test
4271
docs-test: ## Test if documentation can be built without warnings or errors
43-
@uv run mkdocs build -s
72+
$(call ECHO_BANNER, "Testing whether docs can be build")
73+
uvx mkdocs build -s
4474

45-
.PHONY: docs
46-
docs: ## Build and serve the documentation
47-
@uv run mkdocs serve
75+
.PHONY: serve
76+
serve: ## Build and serve the documentation
77+
$(call ECHO_BANNER, "Build and serve docs for local development")
78+
uvx mkdocs serve
4879

49-
.PHONY: help
50-
help:
51-
@uv run python -c "import re; \
52-
[[print(f'\033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([a-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]"
5380

54-
.DEFAULT_GOAL := help
81+
############################################################################
82+
#= CLEANUP
83+
84+
.PHONY: clean
85+
clean: ## Remove temporary and backup files
86+
$(call ECHO_BANNER, "Remove temporary and backup files")
87+
rm -frv **/*~ **/*.bak
88+
89+
.PHONY: cleaner
90+
cleaner: clean ## Remove files and directories that are easily rebuilt
91+
$(call ECHO_BANNER, "Remove files and directories that are easily rebuilt")
92+
rm -frv .cache build dist docs/_build
93+
rm -frv **/__pycache__
94+
rm -frv **/*.egg-info
95+
rm -frv **/*.pyc
96+
rm -frv **/*.orig
97+
rm -frv **/*.rej
98+
99+
.PHONY: cleanest
100+
cleanest: cleaner ## Remove all files that can be rebuilt
101+
$(call ECHO_BANNER, "Remove files and directories that can be rebuilt")
102+
rm -frv .eggs .tox .venv venv
103+
104+
.PHONY: distclean
105+
distclean: cleanest ## Remove untracked files and other detritus
106+
@echo "❌ Remove untracked files and other detritus -- Too dangerous... do this yourself"
107+
# git clean -df

0 commit comments

Comments
 (0)