Skip to content

Commit e38a8ba

Browse files
hroncokFidget-Spinner
authored andcommitted
pythongh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (pythonGH-142455)
(cherry picked from commit bcf90de) Co-authored-by: Miro Hrončok <[email protected]> Co-authored-by: Ken Jin <[email protected]>
1 parent ab8ac4b commit e38a8ba

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
When calculating the digest of the JIT stencils input, sort the hashed files
2+
by filenames before adding their content to the hasher. This ensures
3+
deterministic hash input and hence deterministic hash, independent on
4+
filesystem order.

Tools/jit/_targets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _compute_digest(self, out: pathlib.Path) -> str:
5656
# Exclude cache files from digest computation to ensure reproducible builds.
5757
if dirpath.endswith("__pycache__"):
5858
continue
59-
for filename in filenames:
59+
for filename in sorted(filenames):
6060
hasher.update(pathlib.Path(dirpath, filename).read_bytes())
6161
return hasher.hexdigest()
6262

0 commit comments

Comments
 (0)