fix(whl_library): actually apply patches and warn if RECORD file patch is needed (#1637)
Before this PR there was a typo, that was actually causing the
patching function to not use the provided patches. With this change
we are finally correctly doing it. After fixing this bug I noticed
that `repository_ctx.patch` results in files with `CRLF` on Windows,
which made me make the `RECORD` mismatch to be a warning rather than
a hard failure to make the CI happy and allow users on Windows to
patch wheels but see a warning if they have a multi-platform bazel
setup.
The `CRLF` endings on Windows issue is fixed in
bazelbuild/bazel@07e0d316a345a3cb2593f98525320590bbc56e30
Related #1631, #1639.
diff --git a/python/private/repack_whl.py b/python/private/repack_whl.py
index 074e30d..be113ef 100644
--- a/python/private/repack_whl.py
+++ b/python/private/repack_whl.py
@@ -114,6 +114,11 @@
help="The original wheel file that we have patched.",
)
parser.add_argument(
+ "--record-patch",
+ type=pathlib.Path,
+ help="The output path that we are going to write the RECORD file patch to.",
+ )
+ parser.add_argument(
"output",
type=pathlib.Path,
help="The output path that we are going to write a new file to.",
@@ -163,8 +168,10 @@
got_record,
out.distinfo_path("RECORD"),
)
- logging.exception(f"Please also patch the RECORD file with:\n{record_diff}")
- return 1
+ args.record_patch.write_text(record_diff)
+ logging.warning(
+ f"Please apply patch to the RECORD file ({args.record_patch}):\n{record_diff}"
+ )
if __name__ == "__main__":