Skip to content

Commit 5e5503d

Browse files
committed
Skip wheel patching with empty patches
Fixes #2263
1 parent 71417c5 commit 5e5503d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ A brief description of the categories of changes:
5050
* (bzlmod) In hybrid bzlmod with WORKSPACE builds,
5151
`python_register_toolchains(register_toolchains=True)` is respected
5252
([#1675](https://github.com/bazelbuild/rules_python/issues/1675)).
53+
* (pip) Skip patching wheels not matching `pip.override`'s `file`
54+
([#2294](https://github.com/bazelbuild/rules_python/pull/2294)).
5355

5456
### Added
5557
* (py_wheel) Now supports `compress = (True|False)` to allow disabling

python/private/pypi/patch_whl.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def patch_whl(rctx, *, python_interpreter, whl_path, patches, **kwargs):
6060
if not rctx.delete(whl_file_zip):
6161
fail("Failed to remove the symlink after extracting")
6262

63+
if not patches:
64+
fail("Trying to patch wheel without any patches")
65+
6366
for patch_file, patch_strip in patches.items():
6467
rctx.patch(patch_file, strip = patch_strip)
6568

python/private/pypi/whl_library.bzl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,16 @@ def _whl_library_impl(rctx):
266266
if whl_path.basename in patch_dst.whls:
267267
patches[patch_file] = patch_dst.patch_strip
268268

269-
whl_path = patch_whl(
270-
rctx,
271-
op = "whl_library.PatchWhl({}, {})".format(rctx.attr.name, rctx.attr.requirement),
272-
python_interpreter = python_interpreter,
273-
whl_path = whl_path,
274-
patches = patches,
275-
quiet = rctx.attr.quiet,
276-
timeout = rctx.attr.timeout,
277-
)
269+
if patches:
270+
whl_path = patch_whl(
271+
rctx,
272+
op = "whl_library.PatchWhl({}, {})".format(rctx.attr.name, rctx.attr.requirement),
273+
python_interpreter = python_interpreter,
274+
whl_path = whl_path,
275+
patches = patches,
276+
quiet = rctx.attr.quiet,
277+
timeout = rctx.attr.timeout,
278+
)
278279

279280
target_platforms = rctx.attr.experimental_target_platforms
280281
if target_platforms:

0 commit comments

Comments
 (0)