8000 packaging/piptool: sort wheels and extras for deterministic output · bazel-contrib/rules_python@30f9d81 · GitHub
[go: up one dir, main page]

Skip to content

Commit 30f9d81

Browse files
committed
packaging/piptool: sort wheels and extras for deterministic output
1 parent dd7f9c5 commit 30f9d81

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packaging/piptool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def pip_main(argv):
105105
parser.add_argument('--extra_pip_args', action='store',
106106
help=('Extra arguments to pass down to pip.'))
107107

108+
def sort_wheels(whls):
109+
"""Sorts a list of wheels deterministically."""
110+
return sorted(whls, key=lambda w: w.distribution() + '_' + w.version())
111+
108112
def determine_possible_extras(whls):
109113
"""Determines the list of possible "extras" for each .whl
110114
@@ -153,7 +157,7 @@ def is_possible(distro, extra):
153157
return {
154158
whl: [
155159
extra
156-
for extra in whl.extras()
160+
for extra in sorted(whl.extras())
157161
if is_possible(whl.distribution(), extra)
158162
]
159163
for whl in whls
@@ -177,7 +181,7 @@ def list_whls():
177181
if fname.endswith('.whl'):
178182
yield os.path.join(root, fname)
179183

180-
whls = [Wheel(path) for path in list_whls()]
184+
whls = sort_wheels(Wheel(path) for path in list_whls())
181185
possible_extras = determine_possible_extras(whls)
182186

183187
def repository_name(wheel):

0 commit comments

Comments
 (0)
0