From 9e8a0c87883641b2f239c077d58f410f96847fdb Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 29 May 2024 18:17:43 +0300 Subject: [PATCH 1/4] makefile/RTD: Use uv if installed --- .readthedocs.yml | 3 +++ Doc/Makefile | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 59830c79a404e0..d0d0c3b93ed207 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -26,6 +26,9 @@ build: exit 183; fi + - asdf plugin add uv + - asdf install uv latest + - asdf global uv latest - make -C Doc venv html - mkdir _readthedocs - mv Doc/build/html _readthedocs/html diff --git a/Doc/Makefile b/Doc/Makefile index 1cbfc722b010f5..dad82959ca97f5 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -152,7 +152,11 @@ 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 + if uv --version > /dev/null; then \ + $(VENVDIR)/bin/sphinx-autobuild --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install sphinx-autobuild; \ + else \ + $(VENVDIR)/bin/sphinx-autobuild --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install sphinx-autobuild; \ + fi .PHONY: htmllive htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild @@ -174,10 +178,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 @@ -237,7 +246,11 @@ dist: .PHONY: check check: 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 From 771deff314339d317d511d1a7cdc8980a658f03c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 29 May 2024 18:19:26 +0300 Subject: [PATCH 2/4] Refactor into ensure-pre-commit --- Doc/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index dad82959ca97f5..dc4e709364a77c 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -244,13 +244,16 @@ dist: rm -r dist/python-$(DISTVERSION)-docs-texinfo rm dist/python-$(DISTVERSION)-docs-texinfo.tar -.PHONY: check -check: venv +.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; + fi + +.PHONY: check +check: ensure-pre-commit $(VENVDIR)/bin/python3 -m pre_commit run --all-files .PHONY: serve From ca647a3c2f8891c1ce8b71b96791493de98e1e1a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 29 May 2024 18:36:43 +0300 Subject: [PATCH 3/4] Refactor into ensure_package --- Doc/Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index dc4e709364a77c..85f4ef0f6b8aa7 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -152,11 +152,7 @@ htmlview: html .PHONY: ensure-sphinx-autobuild ensure-sphinx-autobuild: venv - if uv --version > /dev/null; then \ - $(VENVDIR)/bin/sphinx-autobuild --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install sphinx-autobuild; \ - else \ - $(VENVDIR)/bin/sphinx-autobuild --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install sphinx-autobuild; \ - fi + $(call ensure_package,sphinx-autobuild) .PHONY: htmllive htmllive: SPHINXBUILD = $(VENVDIR)/bin/sphinx-autobuild @@ -244,16 +240,17 @@ dist: rm -r dist/python-$(DISTVERSION)-docs-texinfo rm dist/python-$(DISTVERSION)-docs-texinfo.tar -.PHONY: ensure-pre-commit -ensure-pre-commit: venv +define ensure_package if uv --version > /dev/null; then \ - $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install pre-commit; \ + $(VENVDIR)/bin/python3 -m $(1) --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install $(1); \ else \ - $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit; \ + $(VENVDIR)/bin/python3 -m $(1) --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install $(1); \ fi +endef .PHONY: check -check: ensure-pre-commit +check: venv + $(call ensure_package,pre-commit) $(VENVDIR)/bin/python3 -m pre_commit run --all-files .PHONY: serve From 4861f696ce2813ceab4e0910fc7cef533698118b Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Thu, 30 May 2024 09:30:33 +0300 Subject: [PATCH 4/4] Underscore --- Doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Makefile b/Doc/Makefile index 85f4ef0f6b8aa7..c70768754834dd 100644 --- a/Doc/Makefile +++ b/Doc/Makefile @@ -250,7 +250,7 @@ endef .PHONY: check check: venv - $(call ensure_package,pre-commit) + $(call ensure_package,pre_commit) $(VENVDIR)/bin/python3 -m pre_commit run --all-files .PHONY: serve