66# You can set these variables from the command line.
77PYTHON = python3
88VENVDIR = ./venv
9+ UV = uv
910SPHINXBUILD = PATH=$(VENVDIR ) /bin:$$PATH sphinx-build
1011BLURB = PATH=$(VENVDIR ) /bin:$$PATH blurb
1112JOBS = auto
@@ -150,14 +151,10 @@ gettext: build
150151htmlview : html
151152 $(PYTHON ) -c " import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
152153
153- .PHONY : ensure-sphinx-autobuild
154- ensure-sphinx-autobuild : venv
155- $(call ensure_package,sphinx-autobuild)
156-
157154.PHONY : htmllive
158155htmllive : SPHINXBUILD = $(VENVDIR ) /bin/sphinx-autobuild
159156htmllive : SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
160- htmllive : ensure -sphinx-autobuild html
157+ htmllive : _ensure -sphinx-autobuild html
161158
162159.PHONY : clean
163160clean : clean-venv
@@ -174,15 +171,15 @@ venv:
174171 echo " To recreate it, remove it first with \` make clean-venv'." ; \
175172 else \
176173 echo " Creating venv in $( VENVDIR) " ; \
177- if uv --version > /dev/null; then \
178- uv venv $(VENVDIR ) ; \
179- VIRTUAL_ENV=$(VENVDIR ) uv pip install -r $(REQUIREMENTS ) ; \
174+ if $( UV ) --version > /dev/null 2>&1 ; then \
175+ $( UV ) venv $(VENVDIR ) ; \
176+ VIRTUAL_ENV=$(VENVDIR ) $( UV ) pip install -r $(REQUIREMENTS ) ; \
180177 else \
181178 $(PYTHON ) -m venv $(VENVDIR ) ; \
182179 $(VENVDIR ) /bin/python3 -m pip install --upgrade pip; \
183180 $(VENVDIR ) /bin/python3 -m pip install -r $(REQUIREMENTS ) ; \
184- echo " The venv has been created in the $( VENVDIR) directory" ; \
185181 fi ; \
182+ echo " The venv has been created in the $( VENVDIR) directory" ; \
186183 fi
187184
188185.PHONY : dist
@@ -240,17 +237,24 @@ dist:
240237 rm -r dist/python-$(DISTVERSION)-docs-texinfo
241238 rm dist/python-$(DISTVERSION)-docs-texinfo.tar
242239
243- define ensure_package
244- if uv --version > /dev/null; then \
245- $(VENVDIR ) /bin/python3 -m $(1 ) --version > /dev/null || VIRTUAL_ENV=$(VENVDIR ) uv pip install $(1 ) ; \
240+ .PHONY : _ensure-package
241+ _ensure-package : venv
242+ if $( UV) --version > /dev/null 2>&1 ; then \
243+ VIRTUAL_ENV=$(VENVDIR ) $(UV ) pip install $(PACKAGE ) ; \
246244 else \
247- $(VENVDIR ) /bin/python3 -m $( 1 ) --version > /dev/null || $( VENVDIR ) /bin/python3 -m pip install $(1 ) ; \
245+ $(VENVDIR ) /bin/python3 -m pip install $(PACKAGE ) ; \
248246 fi
249- endef
247+
248+ .PHONY : _ensure-pre-commit
249+ _ensure-pre-commit :
250+ make _ensure-package PACKAGE=pre-commit
251+
252+ .PHONY : _ensure-sphinx-autobuild
253+ _ensure-sphinx-autobuild :
254+ make _ensure-package PACKAGE=sphinx-autobuild
250255
251256.PHONY : check
252- check : venv
253- $(call ensure_package,pre_commit)
257+ check : _ensure-pre-commit
254258 $(VENVDIR ) /bin/python3 -m pre_commit run --all-files
255259
256260.PHONY : serve
0 commit comments