astral-sh/uv

Consider adding workspace members as sources in `uv init`

Open

#5,388 opened on Jul 24, 2024

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Rust (3,111 forks)batch import
cligood first issueprojects

Repository metrics

Stars
 (84,934 stars)
PR merge metrics
 (Avg merge 7d 16h) (259 merged PRs in 30d)

Description

Initializing as workspace member adds it to the root package workspace members but does not add it as a dependency, e.g.:

❯ uv init
❯ uv init foo
Adding `foo` as member of workspace `/Users/zb/workspace/example`
Initialized project `foo` at `/Users/zb/workspace/example/foo`
❯ cat pyproject.toml
[project]
name = "example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = []

[tool.uv]
dev-dependencies = []

[tool.uv.workspace]
members = ["foo"]

uv add will do so:

❯ uv add foo
❯ cat pyproject.toml
[project]
name = "example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "foo",
]

[tool.uv]
dev-dependencies = []

[tool.uv.workspace]
members = ["foo"]

[tool.uv.sources]
foo = { workspace = true }

We should something like:

  • Add a toggle to control adding to the current workspace in a single invocation
  • Determine the default behavior
  • If not added by default, show a hint suggesting how to add it

Contributor guide