66.DEFAULT_GOAL := help
77default : help
88
9- SHELL: =/bin/bash
9+ ifeq ("","$(shell command -v zsh) ")
10+ $(error "zsh not found; you must install zsh first")
11+ endif
12+ SHELL: =zsh -eu -o pipefail -o null_glob
1013
1114COLOR_RESET =\033[0m
1215COLOR_CYAN_BOLD =\033[1;36m
13- define ECHO_BANNER
16+ define INFO_MESSAGE
1417 @echo -e "⏩$(COLOR_CYAN_BOLD )$(1 )$(COLOR_RESET ) "
1518endef
1619
@@ -20,85 +23,73 @@ endef
2023.PHONY : help
2124help : # # Display help message
2225 @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-
26+ [[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
2527
2628# ###########################################################################
2729# = SETUP, INSTALLATION, PACKAGING
2830
2931install : devready
3032.PHONY : devready
3133devready : # # 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" )
34+ $(call INFO_MESSAGE, Prepare local dev env: Create virtual env and install the pre-commit hooks)
3335 uv sync --dev
34- uvx pre-commit install
36+ uv run pre-commit install
37+ @echo ' ⚠️ You must activate the virtual env with `source .venv/bin/activate`'
3538
3639.PHONY : build
3740build : # # Build package
38- $(call ECHO_BANNER , "Building package")
41+ $(call INFO_MESSAGE , "Building package")
3942 rm -fr dist
40- uvx --from build pyproject-build --installer uv
41-
42- .PHONY : publish
43- publish : # # Publish a release to PyPI.
44- $(call ECHO_BANNER, "Publishing to PyPI.")
45- uvx publish
46-
43+ uv build
4744
4845# ###########################################################################
49- # = TESTING AND CODE QUALITY
46+ # = FORMATTING, TESTING, AND CODE QUALITY
5047
51- .PHONY : check
52- cqa check : # # Run code quality tools .
53- $(call ECHO_BANNER , "Checking lock file consistency with 'pyproject.toml' ")
48+ .PHONY : cqa
49+ cqa : # # Run code quality assessments .
50+ $(call INFO_MESSAGE , "Checking lock file consistency")
5451 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
52+ $(call INFO_MESSAGE , "Linting and reformatting files ")
53+ uv run pre-commit run -a
54+ $(call INFO_MESSAGE , "Checking for obsolete dependencies")
55+ uv run deptry src
5956
6057.PHONY : test
6158test : # # Test the code with pytest
6259 @echo " 🚀 Testing code: Running pytest"
63- pytest
64- # uvx python -m pytest # --cov --cov-config=pyproject.toml --cov-report=xml
65-
60+ uv run pytest
6661
6762# ###########################################################################
6863# = DOCUMENTATION
6964
65+ .PHONY : docs-serve
66+ docs-serve : # # Build and serve the documentation
67+ $(call INFO_MESSAGE, "Build and serve docs for local development")
68+ uv run mkdocs serve
69+
7070.PHONY : docs-test
7171docs-test : # # Test if documentation can be built without warnings or errors
72- $(call ECHO_BANNER, "Testing whether docs can be build")
73- uvx mkdocs build -s
74-
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
79-
72+ $(call INFO_MESSAGE, "Testing whether docs can be build")
73+ uv run mkdocs build -s
8074
8175# ###########################################################################
8276# = CLEANUP
8377
8478.PHONY : clean
8579clean : # # Remove temporary and backup files
86- $(call ECHO_BANNER , "Remove temporary and backup files")
80+ $(call INFO_MESSAGE , "Remove temporary and backup files")
8781 rm -frv ** /* ~ ** /* .bak
8882
8983.PHONY : cleaner
9084cleaner : clean # # Remove files and directories that are easily rebuilt
91- $(call ECHO_BANNER , "Remove files and directories that are easily rebuilt")
85+ $(call INFO_MESSAGE , "Remove files and directories that are easily rebuilt")
9286 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
87+ rm -frv ** /* .pyc ** /__pycache__ ** /* .egg-info
88+ rm -frv ** /* .orig ** /* .rej
9889
9990.PHONY : cleanest
10091cleanest : cleaner # # Remove all files that can be rebuilt
101- $(call ECHO_BANNER , "Remove files and directories that can be rebuilt")
92+ $(call INFO_MESSAGE , "Remove files and directories that can be rebuilt")
10293 rm -frv .eggs .tox .venv venv
10394
10495.PHONY : distclean
0 commit comments