From 686e170747a03b34fca6f8f14fe8f933987b650c Mon Sep 17 00:00:00 2001 From: alm Date: Sun, 31 Aug 2025 00:21:25 +0300 Subject: [PATCH] gh-138061: Exclude __pycache__ directory from the computed digest in the JIT stencils (GH-138131) Exclude the __pycache__ directory when generating the digest in the JIT stencils (cherry picked from commit d3d94e0ed715829d9bf93ef9c35e04832962f19f) Co-authored-by: alm --- .../next/Build/2025-08-27-09-52-45.gh-issue-138061.fMVS9w.rst | 1 + Tools/jit/_targets.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2025-08-27-09-52-45.gh-issue-138061.fMVS9w.rst diff --git a/Misc/NEWS.d/next/Build/2025-08-27-09-52-45.gh-issue-138061.fMVS9w.rst b/Misc/NEWS.d/next/Build/2025-08-27-09-52-45.gh-issue-138061.fMVS9w.rst new file mode 100644 index 00000000000000..7af79d0b87ef55 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-08-27-09-52-45.gh-issue-138061.fMVS9w.rst @@ -0,0 +1 @@ +Ensure reproducible builds by making JIT stencil header generation deterministic. diff --git a/Tools/jit/_targets.py b/Tools/jit/_targets.py index 34f4e20b95d19b..fe953ddddcfc08 100644 --- a/Tools/jit/_targets.py +++ b/Tools/jit/_targets.py @@ -53,6 +53,9 @@ def _compute_digest(self, out: pathlib.Path) -> str: hasher.update(PYTHON_EXECUTOR_CASES_C_H.read_bytes()) hasher.update((out / "pyconfig.h").read_bytes()) for dirpath, _, filenames in sorted(os.walk(TOOLS_JIT)): + # Exclude cache files from digest computation to ensure reproducible builds. + if dirpath.endswith("__pycache__"): + continue for filename in filenames: hasher.update(pathlib.Path(dirpath, filename).read_bytes()) return hasher.hexdigest()