@@ -28,7 +28,7 @@ htmlview: html
2828
2929.PHONY : ensure-sphinx-autobuild
3030ensure-sphinx-autobuild : venv
31- $(VENVDIR ) /bin/sphinx-autobuild --version > /dev/null || $( VENVDIR ) /bin/python3 -m pip install sphinx-autobuild
31+ $(call ensure_package, sphinx-autobuild)
3232
3333# # htmllive to rebuild and reload HTML files in your browser
3434.PHONY : htmllive
@@ -82,17 +82,18 @@ venv:
8282 echo " The venv has been created in the $( VENVDIR) directory" ; \
8383 fi
8484
85- .PHONY : ensure-pre-commit
86- ensure-pre-commit : venv
85+ define ensure_package
8786 if uv --version > /dev/null; then \
88- $(VENVDIR ) /bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR ) uv pip install pre-commit ; \
87+ $(VENVDIR ) /bin/python3 -m $( 1 ) --version > /dev/null || VIRTUAL_ENV=$(VENVDIR ) uv pip install $( 1 ) ; \
8988 else \
90- $(VENVDIR ) /bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR ) /bin/python3 -m pip install pre-commit; \
91- fi ;
89+ $(VENVDIR ) /bin/python3 -m $(1 ) --version > /dev/null || $(VENVDIR ) /bin/python3 -m pip install $(1 ) ; \
90+ fi
91+ endef
9292
9393# # lint to lint all the files
9494.PHONY : lint
95- lint : ensure-pre-commit
95+ lint : venv
96+ $(call ensure_package,pre_commit)
9697 $(VENVDIR ) /bin/python3 -m pre_commit run --all-files
9798
9899# # test to test the Sphinx extensions for PEPs
@@ -102,8 +103,8 @@ test: venv
102103
103104# # spellcheck to check spelling
104105.PHONY : spellcheck
105- spellcheck : ensure-pre-commit
106- $(VENVDIR ) /bin/python3 -m pre_commit --version > /dev/null || $( VENVDIR ) /bin/python3 -m pip install pre-commit
106+ spellcheck : venv
107+ $(call ensure_package, pre_commit)
107108 $(VENVDIR ) /bin/python3 -m pre_commit run --all-files --hook-stage manual codespell
108109
109110.PHONY : help
0 commit comments