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 repository. Basically, do a Git pull on the dependency Git repository 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 repository that references https://github.com/PowerInsight/quantstats.git
uv sync
The file I changed in the Git repository 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
It is the 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 repository:
[tool.uv]
cache-keys = [{ git = { commit = true } }]
I also tried setting this package to always get reinstalled:
[tool.uv]
reinstall-package = ["quantstats"]
What do I need to do for uv to pull from the Git repository dependency on any commit?
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.