linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] docs: Makefile: Inherit PYTHONPYCACHEPREFIX setting as env variable
@ 2025-05-01  8:21 Akira Yokosawa
  2025-05-06 13:07 ` Jonathan Corbet
  2025-05-07 14:44 ` Mauro Carvalho Chehab
  0 siblings, 2 replies; 3+ messages in thread
From: Akira Yokosawa @ 2025-05-01  8:21 UTC (permalink / raw)
  To: Jonathan Corbet, Mauro Carvalho Chehab
  Cc: Linux Doc Mailing List, Andy Shevchenko, Akira Yokosawa

Commit 6c2f0b28d76e ("docs: Makefile: store __pycache__ at the output
directory") assigns a new path to PYTHONPYCACHEPREFIX for building
kernel documentation.

However, it is not necessarily optimal for everyone.

If you find PYTHONPYCACHEPREFIX is already set, it strongly suggests
that the developer has selected the setting as best suited for one's own
workflow.

Use "?=" in the assignment to PYTHONPYCACHEPREFIX so that the path of
$(abspath $(BUILDDIR)/__pycache__) works only as a safeguard.

Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
Mauro,

I left other Makefiles commit 5c5c32d7abd9 ("scripts/kernel-doc.py:
don't create *.pyc files") has touched, as I'm not sure which path to
assign in them.

Additional Notes:

Python's default behavior, which is safe in cases where the source tree
is never shared heterogeneously, can be restored by defining it empty
by saying:

    export PYTHONPYCACHEPREFIX=

As the path in the env var can have white spaces, a quote pair is added
to make it a single token.

Thanks,
Akira
--
 Documentation/Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 59e95ebae786..d30d66ddf1ad 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -82,9 +82,11 @@ loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
 # $5 reST source folder relative to $(src),
 #    e.g. "userspace-api/media" for the linux-tv book-set at ./Documentation/userspace-api/media
 
+PYTHONPYCACHEPREFIX ?= $(abspath $(BUILDDIR)/__pycache__)
+
 quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
       cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \
-	PYTHONPYCACHEPREFIX=$(abspath $(BUILDDIR)/__pycache__) \
+	PYTHONPYCACHEPREFIX="$(PYTHONPYCACHEPREFIX)" \
 	BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(src)/$5/$(SPHINX_CONF)) \
 	$(PYTHON3) $(srctree)/scripts/jobserver-exec \
 	$(CONFIG_SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \

base-commit: c0fe189b590c754f69e0cb87c5b5674cad535cf6
-- 
2.43.0


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

end of thread, other threads:[~2025-05-07 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01  8:21 [PATCH] docs: Makefile: Inherit PYTHONPYCACHEPREFIX setting as env variable Akira Yokosawa
2025-05-06 13:07 ` Jonathan Corbet
2025-05-07 14:44 ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).