]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Fix trouble caused by Python's bytecode cache.
authorBruno Haible <bruno@clisp.org>
Mon, 22 Apr 2024 11:11:05 +0000 (13:11 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 22 Apr 2024 11:11:05 +0000 (13:11 +0200)
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00367.html>.

* 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
gnulib-tool.py

index b3cef64936e8ddcf59663b59526a0cebe9a55766..4a272d326e60afad2f0e90de5c75bdb73e760a26 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-22  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.py: Fix trouble caused by Python's bytecode cache.
+       Reported by Paul Eggert in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00367.html>.
+       * 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  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Make temporary directories recognizable.
index cdcd316909363500abe156d279cd50add9f03560..81537c272ca10f7f953b2b8480367634f7ad1884 100755 (executable)
@@ -144,6 +144,12 @@ else
   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. <https://docs.python.org/3/library/profile.html>.
 #profiler_args="-m cProfile -s tottime"