Skip to content

Feature request: updating dependency version in a lockfile #7019

@Kobzol

Description

@Kobzol

Hi! While migrating an existing Python project to uv, I encountered a situation where a command similar to cargo update --precise would be quite useful. Essentially, I would like to have the option to tell uv to set a package version (usually of a transitive dependency, one that is not specified in dependencies) in a lockfile to a specific version (that is semver compatible with the other dependencies).

I have the following use-case (related to #7018): I'm porting an existing Python project using a requirements.txt lockfile to uv. Let's say that I have a root dependency a that depends on a transitive dependency b>2.1, and the latest published version of b is 2.3. However, in my existing Python environment, I'm using b==2.2, and I want to continue doing that. In theory, according to semver, 2.3 is compatible with 2.2, but theory is not always practice (especially in the world of Python package management :) ).

If I want to move to uv, I'll generate a new project, set dependencies = ["a==xyz"] and generate a lockfile. However, uv will forcefully set the version of b to 2.3, the newest compatible version. I haven't found any way to tell uv to set a specific version of the transitive dependency (aside from manually modifying the lockfile, but that's really not a good solution).

Workaround

What I found to work is to do uv add b==2.2, which will update the lockfile, and then manually delete "b==2.2" from the dependencies array. This seems to work fine, but it would be nice if uv allowed me to do this in a more straightforward way, e.g. with something like uv lock update b=2.2.

Related issue

A bit similar to #6794, but I'm looking for a way to set the version of a specific package to a specific version, not just update everything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions