8000 refactor: provide more detailed error message when wheel installer fa… · philsc/rules_python@d708c7a · GitHub
[go: up one dir, main page]

Skip to content

Commit d708c7a

Browse files
authored
refactor: provide more detailed error message when wheel installer fails (bazel-contrib#1724)
Wheel installer failures can be very confusing because they're run during the repository phase where the isn't a great understanding of what they're doing. This makes the error message for failures provide details to help understand exactly what it was up to.
1 parent 0aa5ea4 commit d708c7a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

python/pip_install/pip_repository.bzl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,21 @@ def _whl_library_impl(rctx):
726726
timeout = rctx.attr.timeout,
727727
)
728728
if result.return_code:
729-
fail("whl_library %s failed: %s (%s) error code: '%s'" % (rctx.attr.name, result.stdout, result.stderr, result.return_code))
729+
fail((
730+
"whl_library '{name}' wheel_installer failed:\n" +
731+
" command: {cmd}\n" +
732+
" environment:\n{env}\n" +
733+
" return code: {return_code}\n" +
734+
"===== stdout start ====\n{stdout}\n===== stdout end===\n" +
735+
"===== stderr start ====\n{stderr}\n===== stderr end===\n"
736+
).format(
737+
name = rctx.attr.name,
738+
cmd = " ".join([str(a) for a in args]),
739+
env = "\n".join(["{}={}".format(k, v) for k, v in environment.items()]),
740+
return_code = result.return_code,
741+
stdout = result.stdout,
742+
stderr = result.stderr,
743+
))
730744

731745
whl_path = rctx.path(json.decode(rctx.read("whl_file.json"))["whl_file"])
732746
if not rctx.delete("whl_file.json"):

0 commit comments

Comments
 (0)
0