Skip to content

Support resolves_to_constraints_file with resolver = "uv" for Python lockfiles #23476

Description

@charlietsai

Is your feature request related to a problem? Please describe.
For Python lockfiles, when resolver = "uv" is set, resolves_to_constraints_file no longer works.

We currently rely on uv pip compile to generate a lockfile and use that as the source of truth for generating the Pants project lockfile. This is because we prefer using uv pip compile to manage package upgrades.

Describe the solution you'd like
It would be great if the resolves_to_constraints_file and resolver = "uv" combination can be supported. We currently have a workaround described below.

Describe alternatives you've considered

We currently use a multi-step workaround:

  • uv pip compile to generate a requirements.lock
  • generate a temp uv project
  • uv add -c requirements.lock to generate a uv.lock
  • pants generate-lockfiles --resolve=python-default --python-resolves="{'python-default': 'uv.lock'}" to transform the uv.lock into the Pants project uv lockfile, python-default.lock

It seems that it should therefore work? I may be missing nuances here.

Additional context
With my workaround approach, I had issues with custom indexes and had to specify them twice in pyproject.toml and pants.toml.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions