astral-sh/uv

Add an option to add a local dependency also as workspace member for `uv add`

Open

#9,634 opened on Dec 4, 2024

View on GitHub
 (5 comments) (1 reaction) (0 assignees)Rust (84,934 stars) (3,111 forks)batch import
enhancementhelp wanted

Description

I'm working with a bit of an unorthodox setup: I have a bunch of different, independent projects. Some of these projects are utilities meant to be used by other projects, and I found that the easiest way to manage this setup is to make the "main" projects workspaces that depend on the utilities packages, which are also members of these workspaces. Something like this:

main_folder
 - workspace A (members and dependencies: utility A, utility B)
 - workspace B (members and dependencies: utility A)
 - workspace C (members and dependencies: utility B)
 - utility A (an uv project)
 - utility B (an uv project)

I know that workspaces are supposed to contain in their folders their members, but this setup lets me deal with uv sync/build/etc without repeating the command for the utilities projects by using --all-packages. Also, I can easily copy pyproject.toml and uv.lock of a workspace and its utilities, and call uv sync --no-install-workspace to easily install all the dependencies of the entire workspace in a Docker container, without installing the projects and utilities themselves.

That said, I can add a local dependency in the CLI using uv add /path/to/package, but I then have to manually edit the pyproject.toml file to make that package also a workspace member.

Would it make sense to have some kind of option, something like --as-member, so that uv add --as-member /path/to/package would add package as a dependency and as a workspace member?

Contributor guide

Add an option to add a local dependency also as workspace member for `uv add` · astral-sh/uv#9634 | Good First Issue