Skip to content

Commit 9846d04

Browse files
committed
Create separate venv for docs and upgrade sphinx packages to latest versions.
1 parent ef681f3 commit 9846d04

File tree

6 files changed

+43
-335
lines changed

6 files changed

+43
-335
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ docs/_build/
7272
# Project-specific files
7373
scratch
7474
env.make
75+
76+
# Docs
77+
docs/.venv

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-22.04
1111
tools:
12-
python: "3.12"
12+
python: "3.12.11"
1313

1414
# Build documentation in the "docs/" directory with Sphinx
1515
sphinx:

Makefile

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ SRC := $(PWD)/src
1212
TESTS := $(PWD)/tests
1313
DOCS := $(PWD)/docs
1414

15+
DOCS_PYTHON_VERSION := 3.12.11
16+
1517
# Load env file
1618
include env.make
1719
export $(shell sed 's/=.*//' env.make)
@@ -60,28 +62,44 @@ upload-test: ## upload package to testpypi repository
6062
upload: ## upload package to pypi repository
6163
TWINE_USERNAME=$(PYPI_USERNAME) TWINE_PASSWORD=$(PYPI_PASSWORD) pipenv run twine upload --skip-existing dist/*
6264

63-
.PHONY: sphinx-generate-requirements
64-
sphinx-generate-requirements: ## Export sphinx-related deps from Pipfile to docs/requirements.txt for Read the Docs
65-
@echo "# Auto-generated for Read the Docs. Do not edit manually." > docs/requirements.txt
66-
@grep -A 1000 '^\[dev-packages\]' Pipfile \
67-
| grep '^sphinx' \
68-
| sed 's/ *= */==/' \
69-
| tr -d '"' \
70-
>> docs/requirements.txt
65+
################################################################################
66+
# DOCS
67+
################################################################################
68+
69+
.PHONY: sphinx-venv-init
70+
sphinx-venv-init: ## Init venv for docs (requires pyenv $(DOCS_PYTHON_VERSION))
71+
cd $(DOCS) && \
72+
command -v pyenv >/dev/null || { echo "pyenv not found"; exit 1; } && \
73+
pyenv versions --bare | grep -q "^$(DOCS_PYTHON_VERSION)$$" || { echo "pyenv $(DOCS_PYTHON_VERSION) not installed"; exit 1; } && \
74+
PYENV_PYTHON=$$(pyenv root)/versions/$(DOCS_PYTHON_VERSION)/bin/python && \
75+
$$PYENV_PYTHON -m venv .venv && \
76+
.venv/bin/pip install --upgrade pip && \
77+
.venv/bin/pip install -r requirements.txt
78+
79+
.PHONY: sphinx-venv-install
80+
sphinx-venv-install: ## Install or update docs venv from requirements.txt
81+
cd $(DOCS) && \
82+
[ -d .venv ] || { echo "Missing .venv — run sphinx-venv-init first."; exit 1; } && \
83+
.venv/bin/pip install -r requirements.txt
84+
85+
.PHONY: sphinx-venv-rm
86+
sphinx-venv-rm: ## Remove docs venv
87+
rm -rf $(DOCS)/.venv
7188

7289
.PHONY: sphinx-html
7390
sphinx-html: ## build the sphinx html
74-
pipenv run make -C docs html
91+
cd $(DOCS) && .venv/bin/sphinx-build -M html . _build
7592

7693
.PHONY: sphinx-rebuild
7794
sphinx-rebuild: ## re-build the sphinx docs
7895
cd $(DOCS) && \
79-
pipenv run make clean && pipenv run make html
96+
.venv/bin/sphinx-build -M clean . _build && \
97+
.venv/bin/sphinx-build -M html . _build
8098

8199
.PHONY: sphinx-autobuild
82100
sphinx-autobuild: ## activate autobuild of docs
83101
cd $(DOCS) && \
84-
pipenv run sphinx-autobuild . _build/html --watch $(SRC)
102+
.venv/bin/sphinx-autobuild . _build/html --watch $(SRC)
85103

86104
################################################################################
87105
# PRE-COMMIT HOOKS
@@ -115,16 +133,16 @@ pre-commit-run: ## run the pre-commit hooks
115133
pipenv-rm: ## remove the virtual environment
116134
pipenv --rm
117135

118-
.PHONY: pipenv-install
119-
pipenv-install: ## setup the virtual environment
136+
.PHONY: pipenv-install-dev
137+
pipenv-install-dev: ## setup the virtual environment, with dev packages
120138
pipenv install --dev
121139

122140
.PHONY: pipenv-install-package
123141
pipenv-install-package: ## install a package (uses PACKAGE)
124142
pipenv install $(PACKAGE)
125143

126-
.PHONY: pipenv-install-package-dev
127-
pipenv-install-package-dev: ## install a dev package (uses PACKAGE)
144+
.PHONY: pipenv-install-dev-package
145+
pipenv-install-dev-package: ## install a dev package (uses PACKAGE)
128146
pipenv install --dev $(PACKAGE)
129147

130148
.PHONY: pipenv-graph

Pipfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ importlib-metadata = "==4.13.0"
1212
pre-commit = "*"
1313
pytest = "7.4.4"
1414
pytest-xdist = "*"
15-
sphinx = "5.3.0"
16-
sphinx-rtd-theme = "2.0.0"
17-
sphinx-autobuild = "2021.3.14"
18-
wheel = "0.41.2"
1915
typing-extensions = "*"
16+
wheel = "0.41.2"
2017

2118
[requires]
2219
python_version = "3.7.17"

0 commit comments

Comments
 (0)