@@ -152,7 +152,7 @@ htmlview: html
152152
153153.PHONY : ensure-sphinx-autobuild
154154ensure-sphinx-autobuild : venv
155- $(VENVDIR ) /bin/sphinx-autobuild --version > /dev/null || $( VENVDIR ) /bin/python3 -m pip install sphinx-autobuild
155+ $(call ensure_package, sphinx-autobuild)
156156
157157.PHONY : htmllive
158158htmllive : SPHINXBUILD = $(VENVDIR ) /bin/sphinx-autobuild
@@ -174,10 +174,15 @@ venv:
174174 echo " To recreate it, remove it first with \` make clean-venv'." ; \
175175 else \
176176 echo " Creating venv in $( VENVDIR) " ; \
177- $(PYTHON ) -m venv $(VENVDIR ) ; \
178- $(VENVDIR ) /bin/python3 -m pip install --upgrade pip; \
179- $(VENVDIR ) /bin/python3 -m pip install -r $(REQUIREMENTS ) ; \
180- echo " The venv has been created in the $( VENVDIR) directory" ; \
177+ if uv --version > /dev/null; then \
178+ uv venv $(VENVDIR ) ; \
179+ VIRTUAL_ENV=$(VENVDIR ) uv pip install -r $(REQUIREMENTS ) ; \
180+ else \
181+ $(PYTHON ) -m venv $(VENVDIR ) ; \
182+ $(VENVDIR ) /bin/python3 -m pip install --upgrade pip; \
183+ $(VENVDIR ) /bin/python3 -m pip install -r $(REQUIREMENTS ) ; \
184+ echo " The venv has been created in the $( VENVDIR) directory" ; \
185+ fi ; \
181186 fi
182187
183188.PHONY : dist
@@ -235,9 +240,17 @@ dist:
235240 rm -r dist/python-$(DISTVERSION)-docs-texinfo
236241 rm dist/python-$(DISTVERSION)-docs-texinfo.tar
237242
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 ) ; \
246+ else \
247+ $(VENVDIR ) /bin/python3 -m $(1 ) --version > /dev/null || $(VENVDIR ) /bin/python3 -m pip install $(1 ) ; \
248+ fi
249+ endef
250+
238251.PHONY : check
239252check : venv
240- $(VENVDIR ) /bin/python3 -m pre_commit --version > /dev/null || $( VENVDIR ) /bin/python3 -m pip install pre-commit
253+ $(call ensure_package, pre_commit)
241254 $(VENVDIR ) /bin/python3 -m pre_commit run --all-files
242255
243256.PHONY : serve
0 commit comments