Skip to content

Commit

Permalink
build: switch Makefile to uv
Browse files Browse the repository at this point in the history
Consistent venv & tool handling
  • Loading branch information
boidolr committed Oct 15, 2024
1 parent 4037f66 commit 1f1f377
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,42 @@
.DEFAULT_GOAL := all


# venv handling: https://github.com/sio/Makefile.venv/blob/master/Makefile.venv
VENVDIR=.venv
MARKER=.initialized-with-Makefile.venv
VENV=$(VENVDIR)/bin


$(VENV):
python3 -m venv $(VENVDIR)
$(VENV)/python3 -m pip install --upgrade pip setuptools wheel


$(VENV)/$(MARKER): $(VENV)


## venv : Initialize virtual environment with dependencies.
.PHONY: venv
venv: $(VENV)/$(MARKER)
$(VENV)/pip install -q .[tests,svg,avif]


.PHONY: all
all: format check test version


.PHONY: sync
sync:
@uv sync --all-extras


.PHONY: help
help: Makefile
@sed -n 's/^##//p' $< | sort


## upgrade : Update pre-commit configuration.
.PHONY: upgrade
upgrade: venv
$(VENV)/pre-commit autoupdate
upgrade: sync
uv run pre-commit autoupdate


## check : Execute pre-commit hooks.
.PHONY: check
check: venv
$(VENV)/pre-commit run --all-files
check: sync
uv run pre-commit run --all-files


## format : Format code.
.PHONY: format
format: venv
$(VENV)/ruff format -q .
format: sync
uv run ruff format -q .


## test : Execute tests.
.PHONY: test
test: venv
$(VENV)/pytest -q
test: sync
uv run pytest -q


## version : Show which version is detected
Expand Down Expand Up @@ -95,9 +80,3 @@ release-minor: release
.PHONY: release-major
release-major: NEXT_VERSION:=$$((${MAJOR}+1)).0.0
release-major: release


## clean : Remove virtual environment.
.PHONY: clean
clean:
rm -r "$(VENVDIR)"

0 comments on commit 1f1f377

Please sign in to comment.