From 7013adaa98f336f89ac377cebda8e9dd7c1e5cd7 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 28 Oct 2024 14:30:16 -0400 Subject: [PATCH] Replace all `$(PYTHON) -m` with `$(UV) run` to force local venv * Be sure to require that UV exists so that all commands work from a fresh checkout * If `.venv` does not exist, create it when checking for UV --- Makefile | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index a336c34e..562544ac 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ include vars.mk .DEFAULT_GOAL := all -.PHONY: build clean cov default deps dev docs ensure-uv fmt fix install it lint test uninstall version help +.PHONY: build clean cov default dev docs ensure-uv _ensure-uv-cmd _ensure-uv-venv fmt fix install it lint test uninstall version help all: dev test lint build -build: +build: ensure-uv $(UV) build clean: @@ -19,15 +19,15 @@ clean: find . -name "__pycache__" -exec rm -rf {} + find . -type d -empty -delete -cov: - $(PYTHON) -m coverage report +cov: dev + $(UV) run coverage report -cov-html: - $(PYTHON) -m coverage html +cov-html: dev + $(UV) run coverage html open htmlcov/index.html -cov-xml: - $(PYTHON) -m coverage xml +cov-xml: dev + $(UV) run coverage xml dev: ensure-uv $(UV) pip install -e '.[dev]' @@ -35,14 +35,18 @@ dev: ensure-uv docs: $(MAKE) -C ./docs -ensure-uv: +$(VENV): + $(UV) venv $(VENV) +_ensure-uv-venv: _ensure-uv-cmd $(VENV) +_ensure-uv-cmd: @if ! command -v $(UV) >/dev/null; then \ $(PYTHON) -m ensurepip && $(PYTHON) -m pip install uv; \ fi +ensure-uv: _ensure-uv-cmd _ensure-uv-venv -fmt: - $(PYTHON) -m ruff check --fix - $(PYTHON) -m ruff format +fmt: dev + $(UV) run ruff check --fix + $(UV) run ruff format install: ensure-uv $(UV) pip install dist/*.whl @@ -50,18 +54,18 @@ install: ensure-uv it: $(MAKE) -C ./integration -lint: - $(PYTHON) -m pyright - $(PYTHON) -m ruff check +lint: dev + $(UV) run pyright + $(UV) run ruff check -test: - $(PYTHON) -m coverage run --source=src -m pytest tests +test: dev + $(UV) run coverage run --source=src -m pytest tests uninstall: ensure-uv $(UV) pip uninstall $(PROJECT_NAME) -version: - @$(PYTHON) -m setuptools_scm +version: dev + @$(UV) run setuptools_scm help: @echo "Makefile Targets"