Skip to content

Commit 538c4e8

Browse files
authored
makefile/RTD: Use uv if installed (#1320)
1 parent 7815469 commit 538c4e8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

.readthedocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ build:
1414
python: "3"
1515

1616
commands:
17+
- asdf plugin add uv
18+
- asdf install uv latest
19+
- asdf global uv latest
1720
- make dirhtml BUILDDIR=_readthedocs
1821
- mv _readthedocs/dirhtml _readthedocs/html

Makefile

+13-4
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ venv:
7070
ensure-venv:
7171
@if [ ! -d $(VENVDIR) ] ; then \
7272
echo "Creating venv in $(VENVDIR)"; \
73-
$(PYTHON) -m venv $(VENVDIR); \
74-
$(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
75-
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
73+
if uv --version > /dev/null; then \
74+
uv venv $(VENVDIR); \
75+
VIRTUAL_ENV=$(VENVDIR) uv pip install -r requirements.txt; \
76+
else \
77+
$(PYTHON) -m venv $(VENVDIR); \
78+
$(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
79+
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
80+
fi; \
7681
echo "The venv has been created in the $(VENVDIR) directory"; \
7782
fi
7883

@@ -175,7 +180,11 @@ check: ensure-venv
175180

176181
.PHONY: lint
177182
lint: venv
178-
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
183+
if uv --version > /dev/null; then \
184+
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install pre-commit; \
185+
else \
186+
$(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit; \
187+
fi;
179188
$(VENVDIR)/bin/python3 -m pre_commit run --all-files
180189

181190
.PHONY: serve

0 commit comments

Comments
 (0)