Skip to content

Commit 8000c95

Browse files
committed
doc/Makefile: Allow to create and use .venv
Add 'setup' target (alias to '.venv') to create virtualenv directory. This is an optional target (not run by default). If .venv exists, it's used in other targets, activation supports only fish and bash/zsh (known shells used by LTP developers, csh/tcsh is ignored atm). This helps to use virtualenv for development, but avoid using it by default (readthedoc uses container with virtualenv, creating it would be waste of time). Add 'distclean' target which removes also .venv/ directory. Link: https://lore.kernel.org/ltp/20250407150133.115790-4-pvorel@suse.cz/ Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent b900b79 commit 8000c95

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

doc/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,33 @@ top_srcdir ?= ..
55

66
include $(top_srcdir)/include/mk/env_pre.mk
77

8+
PYTHON := python3
9+
VENV_DIR := .venv
10+
11+
# only fish and bash/zsh supported
12+
VENV_CMD := if [ "x${FISH_VERSION}" != "x" ]; then . $(VENV_DIR)/bin/activate.fish; else . $(VENV_DIR)/bin/activate; fi
13+
14+
RUN_VENV := if [ -d $(VENV_DIR) ]; then $(VENV_CMD); fi
15+
16+
$(VENV_DIR):
17+
$(PYTHON) -m virtualenv $(VENV_DIR)
18+
$(VENV_CMD) && pip install -r requirements.txt
19+
20+
.PHONY: setup
21+
setup: $(VENV_DIR)
22+
823
${abs_top_builddir}/metadata/ltp.json:
924
$(MAKE) -C ${abs_top_builddir}/metadata
1025

1126
all: ${abs_top_builddir}/metadata/ltp.json
12-
sphinx-build -b html . html
27+
$(RUN_VENV); sphinx-build -b html . html
1328

1429
spelling:
15-
sphinx-build -b spelling -d build/doctree . build/spelling
30+
$(RUN_VENV); sphinx-build -b spelling -d build/doctree . build/spelling
1631

1732
clean:
1833
rm -rf html/ build/ _static/syscalls.rst _static/tests.rst syscalls.tbl \
1934
${abs_top_builddir}/metadata/ltp.json
35+
36+
distclean: clean
37+
rm -rf $(VENV_DIR)

0 commit comments

Comments
 (0)