Skip to content

Patch METADATA file in the whl doesn't work #2992

Closed as not planned
Closed as not planned

Description

@gfrankliu

bazel_dep(name = "rules_python", version = "1.4.1")

There is a python package wheel that is too restrictive on the dependent package version. I tried to use pip.override to patch the METADATA file inside the whl by modifying the Requires-Dist BUT when running bazel run //:requirements.update , it still uses the dependent package version from the unpatched METADATA file. Is that a bug?

Activity

  1. aignas commented on Jun 16, 2025

    @aignas
    Collaborator

    This is not an issue - the bazel run //:requirements.update does not know anything about the patched METADATA as it is considering all of the available packages to find a solution.

    Consider for workarounds:

    • using the lock rule that uses uv that may allow for overrides
    • rules_uv that uses uv under the hood.

    Solving this is currently outside the scope, but PRs fixing this are welcome.

  2. gfrankliu commented on Jan 11, 2026

    @gfrankliu
    ContributorAuthor

    @aignas now that rules_python has uv support builtin, is the requirement override now possible?

  3. gfrankliu commented on Oct 13, 2026

    @gfrankliu
    ContributorAuthor

    resolved by using a scoped override-dependencies in a uv.toml passed to rules_uv’s pip_compile; requires uv 0.11.25 or newer.

    bazel-contrib/rules_uv#265

  4. aignas commented on Oct 13, 2026

    @aignas
    Collaborator

    Does using rules_python lock rule would work in this place?

  5. gfrankliu commented on Oct 14, 2026

    @gfrankliu
    ContributorAuthor

    Yes, the lock rule works for this. Tested with rules_python 2.4.2 + Bazel 8.5.0, using uv's scoped override-dependencies (only replaces package a's requirement on x, so other packages' real requirements on x are still enforced):

    # pyproject.toml
    [project]
    name = "myapp"
    version = "0.0.0"
    dependencies = ["a", "c"]
    
    [tool.uv]
    override-dependencies = [
        { package = { name = "a" }, dependencies = ["x>=1.0"] },
    ]
    # BUILD.bazel
    load("@rules_python//python/uv:lock.bzl", "lock")
    lock(name = "requirements", srcs = ["pyproject.toml"], out = "requirements.txt")
    # MODULE.bazel - scoped overrides need uv >= 0.11.25; the default (0.11.2) fails to parse the inline table
    uv = use_extension("@rules_python//python/uv:uv.bzl", "uv")
    uv.configure(version = "0.13.0")

    Results: bazel run //:requirements.update resolves x==1.0; adding a package that genuinely needs x>=2.0 makes resolution fail instead of being silently overridden, which is what I wanted. No METADATA patching needed.

    Maybe worth bumping the default uv to >= 0.11.25 at some point so this works out of the box.

  6. aignas commented on Oct 15, 2026

    @aignas
    Collaborator

    uv to >= 0.11.25

    SGTM, if you get to making a PR faster than me, I will approve it. :)

  7. gfrankliu commented on Oct 15, 2026

    @gfrankliu
    ContributorAuthor

    Opened #4273 to bump the default uv to 0.13.1 (scoped override-dependencies need uv >= 0.11.25). I picked 0.13.1 over 0.13.0 because it fixes a 0.13.0 regression that broke source distributions containing hard links.

  8. added a commit that references this issue on Oct 16, 2026
    92f36f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions