Skip to content

Conversation

@jwnimmer-tri
Copy link
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
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