Skip to content

Commit bb2aad2

Browse files
authored
fix(py_wheel): add directories in deterministic order (#3194)
A call to `os.listdir` does not return a deterministic result from one run to the next. So for example if the output of a skylib [copy_directory](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/copy_directory_doc.md) is added to a wheel, the files will be in a random order.
1 parent 10d9ab9 commit bb2aad2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ END_UNRELEASED_TEMPLATE
126126
* (pypi) Support `requirements.txt` files that use different versions of the same
127127
package targeting different target platforms.
128128
([#2797](https://github.com/bazel-contrib/rules_python/issues/2797)).
129+
* (py_wheel) Add directories in deterministic order.
129130

130131
{#v0-0-0-added}
131132
### Added

tools/wheelmaker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def add_file(self, package_filename, real_filename):
152152
"""Add given file to the distribution."""
153153

154154
if os.path.isdir(real_filename):
155-
directory_contents = os.listdir(real_filename)
155+
directory_contents = sorted(os.listdir(real_filename))
156156
for file_ in directory_contents:
157157
self.add_file(
158158
"{}/{}".format(package_filename, file_),

0 commit comments

Comments
 (0)