6
6
# You can set these variables from the command line.
7
7
PYTHON = python3
8
8
VENVDIR = ./venv
9
+ UV = uv
9
10
SPHINXBUILD = PATH=$(VENVDIR ) /bin:$$PATH sphinx-build
10
11
BLURB = PATH=$(VENVDIR ) /bin:$$PATH blurb
11
12
JOBS = auto
@@ -150,14 +151,10 @@ gettext: build
150
151
htmlview : html
151
152
$(PYTHON ) -c " import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/html/index.html'))"
152
153
153
- .PHONY : ensure-sphinx-autobuild
154
- ensure-sphinx-autobuild : venv
155
- $(call ensure_package,sphinx-autobuild)
156
-
157
154
.PHONY : htmllive
158
155
htmllive : SPHINXBUILD = $(VENVDIR ) /bin/sphinx-autobuild
159
156
htmllive : SPHINXOPTS = --re-ignore="/venv/" --open-browser --delay 0
160
- htmllive : ensure -sphinx-autobuild html
157
+ htmllive : _ensure -sphinx-autobuild html
161
158
162
159
.PHONY : clean
163
160
clean : clean-venv
@@ -174,15 +171,15 @@ venv:
174
171
echo " To recreate it, remove it first with \` make clean-venv'." ; \
175
172
else \
176
173
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 ) ; \
180
177
else \
181
178
$(PYTHON ) -m venv $(VENVDIR ) ; \
182
179
$(VENVDIR ) /bin/python3 -m pip install --upgrade pip; \
183
180
$(VENVDIR ) /bin/python3 -m pip install -r $(REQUIREMENTS ) ; \
184
- echo " The venv has been created in the $( VENVDIR) directory" ; \
185
181
fi ; \
182
+ echo " The venv has been created in the $( VENVDIR) directory" ; \
186
183
fi
187
184
188
185
.PHONY : dist
@@ -240,17 +237,24 @@ dist:
240
237
rm -r dist/python-$(DISTVERSION)-docs-texinfo
241
238
rm dist/python-$(DISTVERSION)-docs-texinfo.tar
242
239
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 ) ; \
246
244
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 ) ; \
248
246
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
250
255
251
256
.PHONY : check
252
- check : venv
253
- $(call ensure_package,pre_commit)
257
+ check : _ensure-pre-commit
254
258
$(VENVDIR ) /bin/python3 -m pre_commit run --all-files
255
259
256
260
.PHONY : serve
0 commit comments