Skip to content

feat(pypi): add WORKSPACE uv_lock macro - #4374

Draft
rickeylev wants to merge 2 commits into
bazel-contrib:mainfrom
rickeylev:use_uv_lock_rule
Draft

rickeylev wants to merge 2 commits into
bazel-contrib:mainfrom
rickeylev:use_uv_lock_rule

Conversation

@rickeylev

@rickeylev rickeylev commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Bzlmod supports pip.parse(uv_lock = ...) to install PyPI dependencies
from a universal uv.lock file, but WORKSPACE setups still required
platform- or version-specific requirements.txt files for pip_parse.
Maintaining separate lockfile formats across MODULE.bazel and
WORKSPACE duplicated lockfile generation targets and complicated
dependency updates.

Add the uv_lock macro to //python:pip.bzl for WORKSPACE builds.
It decodes uv.lock with @toml.bzl, converts it to requirements
format via uv_lock_to_requirements, and renders the PyPI hub (and
multi-version spoke repositories when python_interpreter_target is a
dict) using the shared pip_repository rendering logic.

Bzlmod supports `pip.parse(uv_lock = ...)` to install PyPI dependencies
from a universal `uv.lock` file, but `WORKSPACE` setups still required
platform- or version-specific `requirements.txt` files for `pip_parse`.
Maintaining separate lockfile formats across `MODULE.bazel` and
`WORKSPACE` duplicated lockfile generation targets and complicated
dependency updates.

Add the `uv_lock` macro to `//python:pip.bzl` for `WORKSPACE` builds.
It decodes `uv.lock` with `@toml.bzl`, converts it to requirements
format via `uv_lock_to_requirements`, and renders the PyPI hub (and
multi-version spoke repositories when `python_interpreter_target` is a
dict) using the shared `pip_repository` rendering logic. Migrate
repository, example, and test lockfiles that used `uv` from
`requirements.txt` to unified `uv.lock` files.
@rickeylev

Copy link
Copy Markdown
Collaborator Author

AI Disclosure

  • Oversight level: semi-autonomous — This PR was created by an AI coding agent under the direction and review of @rickeylev.
  • Comment handling: Review comments and questions on this PR are monitored by @rickeylev, who either responds directly or directs and reviews agent-assisted updates before they are posted.

This is an automatically generated agent comment.

@rickeylev

Copy link
Copy Markdown
Collaborator Author

@aignas is core of this implementation for a low-effort workspace macro to handle uv.lock look promising? Just look at the files under python/private/pypi, the uv_lock.bzl and uv_lock_repo.bzl. (everything else is migration noise).

The basic impl is to convert the uv.lock to requirements using the uv_lock_to_requirements helper. It basically just converts uv.lock to requirements, then feeds that into the pip rules and pip hub rules.

With just a year left for workspace, I didn't want to put a ton of effort into e.g. full API compatibility with pip_parse. But enough that we can move our own workspace off it

…on PR

Propagate transitive dependency-edge markers in uv_lock_to_requirements
and move the repository, example, and test lockfile migrations into a
stacked child PR.
@rickeylev rickeylev changed the title feat(pypi): add WORKSPACE uv_lock macro and migrate lockfiles to uv.lock feat(pypi): add WORKSPACE uv_lock macro Oct 29, 2026

This branch has not been deployed

No deployments
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.

1 participant