diff --git a/src/auditwheel/tools.py b/src/auditwheel/tools.py index 63b32802..1fd215ab 100644 --- a/src/auditwheel/tools.py +++ b/src/auditwheel/tools.py @@ -75,6 +75,13 @@ 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() + if root == in_dir: + # Place the contents of *.dist-info at the end of + # the archive, as recommended by PEP 427. + dirs.sort(key=lambda p: p.endswith(".dist-info")) + for dir in dirs: dname = os.path.join(root, dir) out_dname = os.path.relpath(dname, in_dir) + "/" diff --git a/src/auditwheel/wheeltools.py b/src/auditwheel/wheeltools.py index b9f85b31..4e3a737e 100644 --- a/src/auditwheel/wheeltools.py +++ b/src/auditwheel/wheeltools.py @@ -71,6 +71,8 @@ def rewrite_record(bdist_dir: str) -> None: def walk() -> Generator[str, None, None]: for dir, dirs, files in os.walk(bdist_dir): + dirs.sort() + files.sort() for f in files: yield pjoin(dir, f)