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?
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.