astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
20.02k stars 594 forks source link

Questions about dependency annotation in `pyproject.toml` #5767

Open chrisrodrigue opened 1 month ago

chrisrodrigue commented 1 month ago

Hello all,

I've been browsing the documentation/issues and I'm having trouble finding examples on annotating dependencies in pyproject.toml.

My current use case is to be able to install an editable local dependency, such as another python project nested in my project as a submodule.

I would also like to support users who don't like to use submodules and would rather install my project directly from a git URL with their package manager, with the option to install it as editable so that they can get the entire project and make local modifications if necessary.

The reason it is important to have an editable installation is so that my entire project gets pulled into .venv\src\myproject, including my non-Python API (.venv\src\myproject\api). Otherwise, my project is installed to site-packages and only includes my project's source (myproject\src\myproject\) and not other components that developers may need, such as API or docs.

See below for my comments/questions.

[project]
dependencies = [
    "some_dependency"
    # Where would the editable option go?
    # How should versions be annotated for local or git dependencies?
    # Would the below entries work?
    # "some_dependency @ ssh://git@gitlab.mycompany.com/project/some_dependency.git"
    # "some_dependency @ ./some_dependency/"
]

# Is this section even needed if the URL/path is already in the dependency list using the dep @ url notation?
[tool.uv.sources]
# Submodule approach
some_dependency = { path = "./some_dependency/"}
# Package manager approach
some_dependency = { git = "ssh://git@gitlab.mycompany.com/project/some_dependency.git"}
chrisrodrigue commented 1 month ago

Can workspaces be pulled in from a remote source?

[project]
dependencies = [
    "some_dependency >=0.1.0,<1"
]

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

[tool.uv.workspace]
include = [
  "packages/some_dependency @ ssh://git@gitlab.mycompany.com/project/some_dependency.git"
]