Skip to content

fix(py_wheel): add directories in deterministic order#3194

Merged
rickeylev merged 1 commit intobazel-contrib:mainfrom
jwnimmer-tri:py-wheel-order
Aug 18, 2025
Merged

fix(py_wheel): add directories in deterministic order#3194
rickeylev merged 1 commit intobazel-contrib:mainfrom
jwnimmer-tri:py-wheel-order

Conversation

@jwnimmer-tri
Copy link
Copy Markdown
Contributor

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 is added to a wheel, the files will be in a random order.


if os.path.isdir(real_filename):
directory_contents = os.listdir(real_filename)
directory_contents = sorted(os.listdir(real_filename))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
directory_contents = sorted(os.listdir(real_filename))
# listdir() results are unordered; sort for determinism.
directory_contents = sorted(os.listdir(real_filename))

@rickeylev rickeylev added this pull request to the merge queue Aug 18, 2025
Merged via the queue into bazel-contrib:main with commit bb2aad2 Aug 18, 2025
2 checks passed
ewianda pushed a commit to ewianda/rules_python that referenced this pull request Aug 19, 2025
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants