From e6d8f67fae6c1ec119dcdb7c1af84909a096144f Mon Sep 17 00:00:00 2001 From: Fumitoshi Ukai Date: Fri, 7 Jun 2024 01:34:31 +0000 Subject: [PATCH] autoninja: set PYTHONDONTWRITEBYTECODE=1 if not set during build, lots of python scripts run and generates lots of pycache *pyc in workspace. To keep workspace clean, set PYTHONDONTWRITEBYTECODE=1 in autoninja.py Change-Id: I5ce4c904aa11dd8172672ff9a8e9a06ebf69c9fe Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5599922 Reviewed-by: Erik Staab Commit-Queue: Fumitoshi Ukai Reviewed-by: Philipp Wollermann Reviewed-by: Josip Sokcevic Reviewed-by: Gary Tong Reviewed-by: Gregory Guterman --- autoninja.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoninja.py b/autoninja.py index 1880931a8..597fa18ee 100755 --- a/autoninja.py +++ b/autoninja.py @@ -207,6 +207,11 @@ def _gn_lines(output_dir, path): def main(args): + # if user doesn't set PYTHONPYCACHEPREFIX and PYTHONDONTWRITEBYTECODE + # set PYTHONDONTWRITEBYTECODE=1 not to create many *.pyc in workspace + # and keep workspace clean. + if not os.environ.get("PYTHONPYCACHEPREFIX"): + os.environ.setdefault("PYTHONDONTWRITEBYTECODE", "1") # The -t tools are incompatible with -j t_specified = False j_specified = False