From 121aeec5bbaf60f886896ccfa5a6fb0bd945941f Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 10 May 2024 16:36:04 +0300 Subject: [PATCH] Use uv if installed --- Makefile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 76f5b9df54..c0583059ef 100644 --- a/Makefile +++ b/Makefile @@ -70,9 +70,16 @@ venv: ensure-venv: @if [ ! -d $(VENVDIR) ] ; then \ echo "Creating venv in $(VENVDIR)"; \ - $(PYTHON) -m venv $(VENVDIR); \ - $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ - $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ + if uv --version > /dev/null; then \ + echo "Installing with uv"; \ + uv venv $(VENVDIR); \ + VIRTUAL_ENV=$(VENVDIR) uv pip install -r requirements.txt; \ + else \ + echo "Installing with pip"; \ + $(PYTHON) -m venv $(VENVDIR); \ + $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \ + $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ + fi; \ echo "The venv has been created in the $(VENVDIR) directory"; \ fi @@ -175,7 +182,11 @@ check: ensure-venv .PHONY: lint lint: venv - $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit + if uv --version > /dev/null; then \ + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install pre-commit; \ + else \ + $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit; \ + fi; $(VENVDIR)/bin/python3 -m pre_commit run --all-files .PHONY: serve