pythonuv

How to get uv to git pull dependencies on uv sync?


In uv, I want to add a git repository as a dependency which is easy in itself, but if we commit in the git repository of the dependency I want uv sync to do a git pull for this git repo. Basically do a git pull on the dependency git repo and then apply the changed code for the dependency to my current virtual env.

Here is what I tried:

uv add git+https://github.com/PowerInsight/quantstats.git

Then I make a commit on https://github.com/PowerInsight/quantstats.git in a python file. Then I run this in the repo that reference https://github.com/PowerInsight/quantstats.git

uv sync

The file I changed in the git repo never gets updated in my .venv folder for the referenced dependency: .venv\Lib\site-packages\quantstats

Then tried the same thing with a specific branch:

uv add git+https://github.com/PowerInsight/quantstats.git --branch main

Same problem, it does not get updated on commit.

Then I tried adding this to both the pyproject.toml of my main project and the dependency git repo:

[tool.uv]
cache-keys = [{ git = { commit = true } }]

I also tried setting this package to always get re-installed:

[tool.uv]
reinstall-package = ["quantstats"]

What do I need to do for uv to pull from the git repository dependency on any commit?


Solution

  • TLDR. You can use

    uv sync --upgrade
    

    Explanation.

    Per documentation of uv sync:

    Syncing ensures that all project dependencies are installed and up-to-date with the lockfile.

    The lockfile doesn't change when the remote repository is updated, but it can be upgraded using

    uv lock --upgrade
    

    or

    uv sync --upgrade
    

    allowing for package upgrades.