You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
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"] },
]
# MODULE.bazel - scoped overrides need uv >= 0.11.25; the default (0.11.2) fails to parse the inline tableuv=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.
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.
Activity
aignas commentedon Jun 16, 2025
This is not an issue - the
bazel run //:requirements.updatedoes not know anything about the patchedMETADATAas it is considering all of the available packages to find a solution.Consider for workarounds:
lockrule that usesuvthat may allow for overridesrules_uvthat usesuvunder the hood.Solving this is currently outside the scope, but PRs fixing this are welcome.
gfrankliu commentedon Jan 11, 2026
@aignas now that rules_python has uv support builtin, is the requirement override now possible?
gfrankliu commentedon Oct 13, 2026
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
aignas commentedon Oct 13, 2026
Does using rules_python lock rule would work in this place?
gfrankliu commentedon Oct 14, 2026
Yes, the
lockrule works for this. Tested with rules_python 2.4.2 + Bazel 8.5.0, using uv's scopedoverride-dependencies(only replaces packagea's requirement onx, so other packages' real requirements onxare still enforced):Results:
bazel run //:requirements.updateresolvesx==1.0; adding a package that genuinely needsx>=2.0makes 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.
aignas commentedon Oct 15, 2026
SGTM, if you get to making a PR faster than me, I will approve it. :)
gfrankliu commentedon Oct 15, 2026
Opened #4273 to bump the default uv to 0.13.1 (scoped
override-dependenciesneed 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.build(uv): bump default uv to 0.13.1 (bazel-contrib#4273)