summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-23 19:48:42 (GMT)
committerGitHub <noreply@github.com>2024-06-23 19:48:42 (GMT)
commit1aadb51838aece99932c23bb0a4b50af07b365b4 (patch)
tree63a96452c12bedef1d4500d788ce7e5f49cb01d5 /Doc
parent6be1048e27f1f2eb35c45d17f3bb8760ec694550 (diff)
downloadcpython-1aadb51838aece99932c23bb0a4b50af07b365b4.zip
cpython-1aadb51838aece99932c23bb0a4b50af07b365b4.tar.gz
cpython-1aadb51838aece99932c23bb0a4b50af07b365b4.tar.bz2
[3.13] Docs makefile/RTD: Use uv if installed (GH-120711) (#120922)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/Makefile25
1 files changed, 19 insertions, 6 deletions
diff --git a/Doc/Makefile b/Doc/Makefile
index 1cbfc72..c707687 100644
--- a/Doc/Makefile
+++ b/Doc/Makefile
@@ -152,7 +152,7 @@ htmlview: html
.PHONY: ensure-sphinx-autobuild
ensure-sphinx-autobuild: venv
- $(VENVDIR)/bin/sphinx-autobuild --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install sphinx-autobuild
+ $(call ensure_package,sphinx-autobuild)
.PHONY: htmllive
htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild
@@ -174,10 +174,15 @@ 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 --upgrade pip; \
- $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \
- echo "The venv has been created in the $(VENVDIR) directory"; \
+ if uv --version > /dev/null; then \
+ uv venv $(VENVDIR); \
+ VIRTUAL_ENV=$(VENVDIR) uv pip install -r $(REQUIREMENTS); \
+ else \
+ $(PYTHON) -m venv $(VENVDIR); \
+ $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
+ $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \
+ echo "The venv has been created in the $(VENVDIR) directory"; \
+ fi; \
fi
.PHONY: dist
@@ -235,9 +240,17 @@ dist:
rm -r dist/python-$(DISTVERSION)-docs-texinfo
rm dist/python-$(DISTVERSION)-docs-texinfo.tar
+define ensure_package
+ if uv --version > /dev/null; then \
+ $(VENVDIR)/bin/python3 -m $(1) --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install $(1); \
+ else \
+ $(VENVDIR)/bin/python3 -m $(1) --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install $(1); \
+ fi
+endef
+
.PHONY: check
check: venv
- $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit
+ $(call ensure_package,pre_commit)
$(VENVDIR)/bin/python3 -m pre_commit run --all-files
.PHONY: serve