Python makefile

.

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
SRC_DIR := <src-dir>  # Change to actual directory name

.PHONY: help lint lint-fix test clean .EXPORT_ALL_VARIABLES
.DEFAULT_GOAL := help

help:  ## 💬 Print help message
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
	| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

lint: venv  ## 
	. .venv/bin/activate \
	&& mypy $(SRC_DIR) \
	&& ruff $(SRC_DIR) tests \
	&& black $(SRC_DIR) tests --check \
	&& isort $(SRC_DIR) tests --check-only

format: venv ## 
	. .venv/bin/activate \
	&& ruff $(SRC_DIR) tests --fix \
	&& black $(SRC_DIR) tests \
	&& isort $(SRC_DIR) tests

# ============================================================================

venv: .venv/touchfile

.venv/touchfile: requirements-dev.txt
	python3 -m venv .venv
	. .venv/bin/activate; pip install -Ur requirements-dev.txt
	touch .venv/touchfile
Built with Hugo. Theme Stack designed by Jimmy