Skip to content

fix(pypi): repack patched wheels with Bazel's zipper - #4486

Merged
rickeylev merged 3 commits into
bazel-contrib:mainfrom
jgautier-dd:fix-pypi-repack-whl-zipper
Nov 15, 2026
Merged

rickeylev merged 3 commits into
bazel-contrib:mainfrom
jgautier-dd:fix-pypi-repack-whl-zipper

Conversation

@jgautier-dd

@jgautier-dd jgautier-dd commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Patching a wheel with pip.override repacks it with the host zip, so
the repository rule fails on a host without a zip binary, such as a
minimal container.

To fix, use Bazel's bundled zipper on non-Windows hosts via a params
file (name=path entries), falling back to host zip only when file
paths contain = or a newline. The zipper also writes a fixed
timestamp, so the repacked wheel is reproducible.

Patching a wheel with `pip.override` repacks it with the host `zip`, so
the repository rule fails on a host without a `zip` binary, such as a
minimal container.

To fix, use Bazel's bundled zipper on non-Windows hosts when it is
present, and keep `zip` as the fallback. The file list goes through a
params file, because the zipper takes `name=path` entries. Paths it can't
express (containing `=` or a newline) use `zip`. The zipper writes a
fixed timestamp, so the repacked wheel is also reproducible.

* Adds `zipper_params_content` and unit tests for it

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread python/private/pypi/patch_whl.bzl Resolved
Comment thread python/private/pypi/patch_whl.bzl Resolved
Comment thread python/private/pypi/patch_whl.bzl Resolved
Comment thread news/repack-whl-zipper.fixed.md Resolved
Wrap Starlark lines within 80 columns, document the uncompressed `c`
mode passed to Bazel's zipper, and condense the news entry to focus on
the user-visible outcome.
@rickeylev

Copy link
Copy Markdown
Collaborator

Other than comment under what conditions the bazel_tools zipper doesn't exist, this LGTM. I set my agent to researching that, but i'm always wary of the claims it comes back with.

All Unix Bazel builds (including source/distro bazel_nojdk builds)
embed @bazel_tools//tools/zip:zipper/zipper in embedded_tools, so drop
the unreachable zipper.exists guard and update the docstrings to reflect
that host zip is only used when paths contain '=' or newlines.
@rickeylev rickeylev changed the title fix(pypi): repack patched wheels with Bazel's zipper when available fix(pypi): repack patched wheels with Bazel's zipper Nov 14, 2026
@rickeylev
rickeylev enabled auto-merge November 14, 2026 22:55
@rickeylev

Copy link
Copy Markdown
Collaborator

Thanks for the fix!

It sounds like you're running on minimal containers? Such issues have been fixed and brought up before, and there's variety of places where there are assumptions about system utilities. PRs to help address that are welcome.

@rickeylev
rickeylev added this pull request to the merge queue Nov 14, 2026
Merged via the queue into bazel-contrib:main with commit 45a8eef Nov 15, 2026
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants