All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 1/2] doc/Makefile: Allow to create and use .venv
@ 2025-02-11 23:35 Petr Vorel
  2025-02-11 23:35 ` [LTP] [PATCH v2 2/2] Makefile: Update 'doc' target to build sphinx doc Petr Vorel
  2025-02-12  8:27 ` [LTP] [PATCH v2 1/2] doc/Makefile: Allow to create and use .venv Andrea Cervesato via ltp
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2025-02-11 23:35 UTC (permalink / raw)
  To: ltp

This is an optional target (not run by default).
If .venv exists, it's used in other targets.

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).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
v1: https://patchwork.ozlabs.org/project/ltp/patch/20250206143421.1571918-4-pvorel@suse.cz/

Changes v1->v2:
* virtualenv is optional
* use variables

 doc/Makefile | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/doc/Makefile b/doc/Makefile
index a07df04d5c..909d9687b8 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -5,14 +5,26 @@ top_srcdir		?= ..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
+PYTHON := python3
+VENV_DIR := .venv
+VENV_CMD := . $(VENV_DIR)/bin/activate
+RUN_VENV := if [ -d $(VENV_DIR) ]; then $(VENV_CMD); fi
+
+# install sphinx only if needed
+INSTALL_SPHINX := $(shell $(PYTHON) -c "import sphinx" 2>/dev/null && echo ":" || echo "pip install sphinx")
+
+$(VENV_DIR):
+	$(PYTHON) -m virtualenv $(VENV_DIR)
+	$(VENV_CMD) && pip install -r requirements.txt && $(INSTALL_SPHINX)
+
 ${abs_top_builddir}/metadata/ltp.json:
 	$(MAKE) -C ${abs_top_builddir}/metadata
 
 all: ${abs_top_builddir}/metadata/ltp.json
-	sphinx-build -b html . html
+	$(RUN_VENV); sphinx-build -b html . html
 
 spelling:
-	sphinx-build -b spelling -d build/doctree . build/spelling
+	$(RUN_VENV); sphinx-build -b spelling -d build/doctree . build/spelling
 
 clean:
-	rm -rf html/ build/ _static/syscalls.rst _static/tests.rst syscalls.tbl
+	rm -rf html/ build/ _static/syscalls.rst _static/tests.rst syscalls.tbl $(VENV_DIR)
-- 
2.47.2


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-12 12:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11 23:35 [LTP] [PATCH v2 1/2] doc/Makefile: Allow to create and use .venv Petr Vorel
2025-02-11 23:35 ` [LTP] [PATCH v2 2/2] Makefile: Update 'doc' target to build sphinx doc Petr Vorel
2025-02-12  8:27 ` [LTP] [PATCH v2 1/2] doc/Makefile: Allow to create and use .venv Andrea Cervesato via ltp
2025-02-12 12:50   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.