Skip to content

Commit

Permalink
Use uv if installed
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed May 10, 2024
1 parent 84b8813 commit 121aeec
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 121aeec

Please sign in to comment.