
Hi Andy,
On Tue, 30 Nov 2021 at 12:04, Andy Shevchenko andriy.shevchenko@linux.intel.com wrote:
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@linux.intel.com
v2: reused our_path tools/binman/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
This look useful, but we cannot rely on 'srcdir' being in the environment. For example, most binman development is done just by running 'binman test' in the source tre. So perhaps default to the current directory is 'srcdir' is not set?
Regards, Simon
diff --git a/tools/binman/main.py b/tools/binman/main.py index 8c1e478d54ce..4d8b124c7468 100755 --- a/tools/binman/main.py +++ b/tools/binman/main.py @@ -16,9 +16,18 @@ import sys import traceback import unittest
+# Get the absolute path to this file at run-time +our_path = os.path.dirname(sys.argv[0])
+# +# 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(our_path, 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__)) sys.path.insert(2, os.path.join(our_path, '..'))
from patman import test_util
2.33.0