2

I want to use uv to install packages and add dependencies, equivalent to the following pip workflow:

git clone https://github.com/<username>/<repository>.git 
cd <repository>
pip install -e .
cd <repository>/<subpackage_1>
pip install -e .
cd ../<subpackage_2>
pip install -e .
...

Is there a simpler way to replicate this process using uv add, such as uv add git+https://github.com/<username>/<repository>.git? From my testing, it seems that uv add with a Git URL does not download any subpackages, and the --subdirectory option is not the right solution. Is there a recommended approach to achieve the same behavior with uv?

1
  • you could create Python/Bash script and use some for-loop to execute it for every needed subpackage. Commented Jul 13 at 13:10

1 Answer 1

4

My recommendation is that you should either declare those sub-projects as dependencies via uv add, or use submodules, but not both.

When I use submodules in a Python project, I don't add those submodules as project requirements, rather, I use a git submodule foreach approach to manipulate them: after cloning, I use git submodule update --init to fetch all the submodules in the state consistent with my top-level repo, and then, e.g., git submodule foreach "uv pip install -e ." to install each submodule (when that makes sense).

If you also declare the submodule as a dependency via uv add git+https://github.com/<username>/<repository>.git you'll get something inconsistent: you will have declared two independent ways of tracking those submodules, and that's bound to lead to conflicts.

Whenever you make changes to the submodules and commit them in the submodules and the top-level repo, that's tracking the exact commits where each submodule should be at a given state in the top-level repo. But if you also use uv add ... for the submodules, you're fetching them again, at a commit that is not tied to your top-level repo, and in a way that won't see changes you make in the submodules on your computer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.