Skip to content

Commit 179eb95

Browse files
committed
Fix BUILD file generation for dirty wheels
When extracting foo_dirty wheel repository, we pass all wheels as an argument to piptool that transitively depend on foo, so that piptool will extract all of them to the foo_dirty repository. After that, piptool generates a BUILD file from the *first* wheel, expecting that to be foo.whl. This was not happening, since we were passing wheels in random order to piptool extract.
1 parent 57f13e8 commit 179eb95

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

WORKSPACE

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ pip_import(
173173
},
174174
remove_runtime_deps = {
175175
# https://github.com/keras-team/keras/issues/10505
176-
"keras-applications": ["keras"],
177-
"keras-preprocessing": ["keras"],
176+
"keras-applications": ["keras", "keras-applications"],
177+
"keras-preprocessing": ["keras", "keras-preprocessing"],
178+
"keras": ["keras"],
178179
},
179180
python = "@python2//:bin/python",
180181
)

rules_python/whl.bzl.tpl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,17 @@ def whl_library(key, all_libs, name, wheel_name, version=None, urls=None, whl=No
5858
)
5959

6060
if dirty_repo_name not in native.existing_rules():
61-
dep_keys = {d.split("[")[0]: None for d in transitive_runtime_deps}
62-
dep_keys[key] = None
61+
# Make sure the current package's wheel is the first element in the "wheels" list,
62+
# since piptool will generate the BUILD file based on that. The remaining wheels
63+
# on the list should be all transitive runtime dependencies (unless explicitly
64+
# dropped at pip_import rule level).
65+
dep_keys = {d.split("[")[0]: None for d in transitive_runtime_deps if d not in remove_runtime_deps}
6366
if whl:
64-
wheels = ["@%s//:%s" % (repository, all_libs[key]["wheel_name"]) for key in dep_keys]
67+
wheels = ["@%s//:%s" % (repository, all_libs[key]["wheel_name"])] + \
68+
["@%s//:%s" % (repository, all_libs[key]["wheel_name"]) for key in dep_keys]
6569
else:
66-
wheels = [_wheel(all_libs, d) for d in dep_keys]
70+
wheels = [_wheel(all_libs, key)] + \
71+
[_wheel(all_libs, d) for d in dep_keys]
6772
extract_wheels(
6873
name = dirty_repo_name,
6974
wheels = wheels,

0 commit comments

Comments
 (0)