Presets / Makefile projet Python
preset Python

Makefile projet Python

makefile  ·  Python

Cibles courantes : install, test, lint, format, run, clean, docker.

make python dev
PYTHON ?= python3
VENV   ?= .venv
BIN    := $(VENV)/bin

.PHONY: help install test lint format run clean docker

help:
	@echo "Cibles : install, test, lint, format, run, clean, docker"

$(VENV)/bin/activate:
	$(PYTHON) -m venv $(VENV)

install: $(VENV)/bin/activate
	$(BIN)/pip install -U pip
	$(BIN)/pip install -r requirements.txt -r requirements-dev.txt

test:
	$(BIN)/pytest -v

lint:
	$(BIN)/ruff check .
	$(BIN)/mypy .

format:
	$(BIN)/black .
	$(BIN)/ruff check --fix .

run:
	$(BIN)/python app.py

clean:
	rm -rf $(VENV) .pytest_cache __pycache__ .mypy_cache .ruff_cache

docker:
	docker build -t myapp:latest .