From eda62139d838f53e4953db26019e5a4b8b805847 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 22 Apr 2024 13:11:05 +0200 Subject: [PATCH 1/2] gnulib-tool.py: Fix trouble caused by Python's bytecode cache. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by Paul Eggert in . * gnulib-tool.py: Set PYTHONPYCACHEPREFIX, so as to avoid creating a __pycache__ directory in the developer's gnulib checkout (only effective with Python ≥ 3.8). --- ChangeLog | 9 +++++++++ gnulib-tool.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index b3cef64936..4a272d326e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-04-22 Bruno Haible + + gnulib-tool.py: Fix trouble caused by Python's bytecode cache. + Reported by Paul Eggert in + . + * gnulib-tool.py: Set PYTHONPYCACHEPREFIX, so as to avoid creating a + __pycache__ directory in the developer's gnulib checkout (only effective + with Python ≥ 3.8). + 2024-04-21 Collin Funk gnulib-tool.py: Make temporary directories recognizable. diff --git a/gnulib-tool.py b/gnulib-tool.py index cdcd316909..81537c272c 100755 --- a/gnulib-tool.py +++ b/gnulib-tool.py @@ -144,6 +144,12 @@ func_fatal_error "python3 not found; try setting GNULIB_TOOL_IMPL=sh" fi +# Tell Python to store the compiled bytecode outside the gnulib directory. +if test -z "$PYTHONPYCACHEPREFIX"; then + PYTHONPYCACHEPREFIX="${TMPDIR-/tmp}/gnulib-python-cache-${USER-$LOGNAME}" + export PYTHONPYCACHEPREFIX +fi + profiler_args= # For profiling, cf. . #profiler_args="-m cProfile -s tottime" -- 2.34.1