|
2 | 2 | #
|
3 | 3 |
|
4 | 4 | # You can set these variables from the command line.
|
5 |
| -PYTHON = python3 |
6 |
| -VENVDIR = ./venv |
7 |
| -SPHINXBUILD = $(VENVDIR)/bin/sphinx-build |
8 |
| -SPHINXOPTS = --fail-on-warning --keep-going |
9 |
| -BUILDDIR = _build |
10 |
| -BUILDER = html |
11 |
| -JOBS = auto |
12 |
| -PAPER = |
13 |
| -SPHINXLINT = $(VENVDIR)/bin/sphinx-lint |
| 5 | +PYTHON = python3 |
| 6 | +VENVDIR = ./venv |
| 7 | +UV = uv |
| 8 | +SPHINXBUILD = $(VENVDIR)/bin/sphinx-build |
| 9 | +SPHINXOPTS = --fail-on-warning --keep-going |
| 10 | +BUILDDIR = _build |
| 11 | +BUILDER = html |
| 12 | +JOBS = auto |
| 13 | +PAPER = |
| 14 | +SPHINXLINT = $(VENVDIR)/bin/sphinx-lint |
| 15 | +REQUIREMENTS = requirements.txt |
14 | 16 |
|
15 | 17 | # Internal variables.
|
16 | 18 | PAPEROPT_a4 = --define latex_paper_size=a4
|
@@ -70,13 +72,13 @@ venv:
|
70 | 72 | ensure-venv:
|
71 | 73 | @if [ ! -d $(VENVDIR) ] ; then \
|
72 | 74 | echo "Creating venv in $(VENVDIR)"; \
|
73 |
| - if uv --version > /dev/null; then \ |
74 |
| - uv venv $(VENVDIR); \ |
75 |
| - VIRTUAL_ENV=$(VENVDIR) uv pip install -r requirements.txt; \ |
| 75 | + if $(UV) --version >/dev/null 2>&1; then \ |
| 76 | + $(UV) venv $(VENVDIR); \ |
| 77 | + VIRTUAL_ENV=$(VENVDIR) $(UV) pip install -r $(REQUIREMENTS); \ |
76 | 78 | else \
|
77 | 79 | $(PYTHON) -m venv $(VENVDIR); \
|
78 | 80 | $(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
|
79 |
| - $(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \ |
| 81 | + $(VENVDIR)/bin/python3 -m pip install -r $(REQUIREMENTS); \ |
80 | 82 | fi; \
|
81 | 83 | echo "The venv has been created in the $(VENVDIR) directory"; \
|
82 | 84 | fi
|
@@ -180,19 +182,21 @@ check: ensure-venv
|
180 | 182 | # Ignore the tools and venv dirs and check that the default role is not used.
|
181 | 183 | $(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role
|
182 | 184 |
|
183 |
| -.PHONY: lint |
184 |
| -lint: venv |
185 |
| - if uv --version > /dev/null; then \ |
186 |
| - $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || VIRTUAL_ENV=$(VENVDIR) uv pip install pre-commit; \ |
| 185 | +.PHONY: _ensure-package |
| 186 | +_ensure-package: venv |
| 187 | + if $(UV) --version >/dev/null 2>&1; then \ |
| 188 | + VIRTUAL_ENV=$(VENVDIR) $(UV) pip install $(PACKAGE); \ |
187 | 189 | else \
|
188 |
| - $(VENVDIR)/bin/python3 -m pre_commit --version > /dev/null || $(VENVDIR)/bin/python3 -m pip install pre-commit; \ |
189 |
| - fi; |
190 |
| - $(VENVDIR)/bin/python3 -m pre_commit run --all-files |
| 190 | + $(VENVDIR)/bin/python3 -m pip install $(PACKAGE); \ |
| 191 | + fi |
191 | 192 |
|
192 |
| -.PHONY: serve |
193 |
| -serve: |
194 |
| - @echo "The 'serve' target was removed, use 'htmlview' instead" \ |
195 |
| - "(see https://github.com/python/cpython/issues/80510)" |
| 193 | +.PHONY: _ensure-pre-commit |
| 194 | +_ensure-pre-commit: |
| 195 | + make _ensure-package PACKAGE=pre-commit |
| 196 | + |
| 197 | +.PHONY: lint |
| 198 | +lint: _ensure-pre-commit |
| 199 | + $(VENVDIR)/bin/python3 -m pre_commit run --all-files |
196 | 200 |
|
197 | 201 | include/branches.csv: include/release-cycle.json
|
198 | 202 | $(VENVDIR)/bin/python3 _tools/generate_release_cycle.py
|
|
0 commit comments