Infra: makefile/RTD: Use uv if installed (#3791)

This commit is contained in:
Hugo van Kemenade 2024-05-29 17:35:25 +03:00 committed by GitHub
parent c85a956398
commit 3b62de3fac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 6 deletions

View File

@ -10,6 +10,9 @@ build:
python: "3"
commands:
- asdf plugin add uv
- asdf install uv latest
- asdf global uv latest
- make dirhtml JOBS=$(nproc) BUILDDIR=_readthedocs/html
sphinx:

View File

@ -71,16 +71,28 @@ venv:
echo "To recreate it, remove it first with \`make clean-venv'."; \
else \
echo "Creating venv in $(VENVDIR)"; \
$(PYTHON) -m venv $(VENVDIR); \
$(VENVDIR)/bin/python3 -m pip install -U pip wheel; \
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
if uv --version > /dev/null; then \
uv venv $(VENVDIR); \
VIRTUAL_ENV=$(VENVDIR) uv pip install -r requirements.txt; \
else \
$(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
.PHONY: ensure-pre-commit
ensure-pre-commit: venv
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;
## lint to lint all the files
.PHONY: lint
lint: venv
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
lint: ensure-pre-commit
$(VENVDIR)/bin/python3 -m pre_commit run --all-files
## test to test the Sphinx extensions for PEPs
@ -90,7 +102,7 @@ test: venv
## spellcheck to check spelling
.PHONY: spellcheck
spellcheck: venv
spellcheck: ensure-pre-commit
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
$(VENVDIR)/bin/python3 -m pre_commit run --all-files --hook-stage manual codespell