[PATCH v1 1/1] binman: Do not pollute source tree when build with `make O=...`

Andy Shevchenko andriy.shevchenko at linux.intel.com
Tue Nov 30 19:42:04 CET 2021


Importing libraries in Python caches the bytecode by default.
Since we run scripts in source tree it ignores the current directory
settings, which is $(srctree), and creates cache just in the middle
of the source tree. Move cache to the current directory.

Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
---
 tools/binman/main.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/binman/main.py b/tools/binman/main.py
index 8c1e478d54ce..d5ab59948ec9 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -16,6 +16,13 @@ import sys
 import traceback
 import unittest
 
+#
+# Do not pollute source tree with cache files:
+# https://stackoverflow.com/a/60024195/2511795
+# https://bugs.python.org/issue33499
+#
+sys.pycache_prefix = os.path.relpath(os.path.dirname(sys.argv[0]), os.environ['srctree'])
+
 # Bring in the patman and dtoc libraries (but don't override the first path
 # in PYTHONPATH)
 our_path = os.path.dirname(os.path.realpath(__file__))
-- 
2.33.0



More information about the U-Boot mailing list