Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make order of files in repaired wheel deterministic #507

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Store entries in zip file in a deterministic order.
In order to make the output zip file reproducible (independent of the
underlying filesystem's directory traversal order), sort each list of
subdirectories and each list of files before adding them to the zip
file.

(Note that we want to sort the dirs list in place, causing os.walk to
traverse the subdirectories in order.)
  • Loading branch information
Benjamin Moody committed Aug 6, 2024
commit 0d01cba955d98d59102fcea4fa487665ecc17967
2 changes: 2 additions & 0 deletions src/auditwheel/tools.py
Original file line number Diff line number Diff line change
@@ -75,6 +75,8 @@ def dir2zip(in_dir: str, zip_fname: str, date_time: datetime | None = None) -> N
compression = zipfile.ZIP_DEFLATED
with zipfile.ZipFile(zip_fname, "w", compression=compression) as z:
for root, dirs, files in os.walk(in_dir):
dirs.sort()
files.sort()
for dir in dirs:
dname = os.path.join(root, dir)
out_dname = os.path.relpath(dname, in_dir) + "/"