From e45f5fbee4a54187fa42d0288bc1e80575011a2a 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] Refactor into ensure_package --- Doc/Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Doc/Makefile b/Doc/Makefile index 50f909c172d29d6..8b2ca13af5e0b5f 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