Open zanieb opened 4 months ago
I'd like to request some clarification on the following:
What is the expected outcome of this operation?
Would the result of uv add "httpx>0.2.0" --git https://github.com/encode/httpx
differ from uv add "httpx>0.2.0" git+https://github.com/encode/httpx
?
Should we consider issues #4604 or #5341 during implementation?
The same as uv add git+https://github.com/encode/httpx
This drops the version specifiers from the project.dependencies
entry for httpx
, they need to be respected.
❯ uv init
warning: `uv init` is experimental and may change without warning
Initialized project `example`
❯ uv add "httpx>0.2.0" git+https://github.com/encode/httpx
warning: `uv add` is experimental and may change without warning
Updated https://github.com/encode/httpx (beb501f)
⠙ Resolving dependencies... warning: `uv.sources` is experimental and may change without warning
Updated https://github.com/encode/httpx (beb501f)
Resolved 8 packages in 379ms
Built example @ file:///Users/zb/workspace/example
Prepared 1 package in 388ms
Uninstalled 1 package in 0.36ms
Installed 1 package in 0.85ms
- example==0.1.0 (from file:///Users/zb/workspace/example)
+ example==0.1.0 (from file:///Users/zb/workspace/example)
❯ cat pyproject.toml
[project]
name = "example"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"httpx",
]
[tool.uv]
dev-dependencies = []
[tool.uv.sources]
httpx = { git = "https://github.com/encode/httpx" }
2. This drops the version specifiers from the
project.dependencies
entry forhttpx
, they need to be respected.
Since issue #5339 has been resolved, is this statement still valid?
Let me summarize a bit. Please correct me if I'm wrong.
git+
prefix is optional).uv add git+URL
.uv add "httpx > 0.2.0" "git+https://github.com/encode/httpx"
uv add "httpx > 0.2.0" --git "https://github.com/encode/httpx"
Unclear Part
If the provided package name differs from the actual one, e.g. uv add "asdf" --git "httpx://github.com/encode/httpx"
this should be considered as uv add "asdf @ git+https://github.com/encode/httpx"
which results in:
dependency = [ "asdf" ]
[tool.uv.sources]
asdf = { git = "https://github.com/encode/httpx" }
Furthermore, if the provided package name differs from the actual one and includes a version specifier
, e.g. uv add "asdf > 0.2.0" --git "https://github.com/encode/httpx"
this should be considered as uv add "asdf @ git+https://github.com/encode/httpx" "asdf > 0.2.0"
which results in:
dependency = ["asdf > 0.2.0"]
[tool.uv.source]
asdf = {git = "https://github.com/encode/httpx"}
Additional complexity arises when the git reference is involved.
If the package name differs from the actual one and includes a version specifier, e.g. uv add "asdf > 0.2.0" --git "https://github.com/encode/httpx" --tag 0.24.1
This cannot be run with a single uv add
command. Currently, you need to execute two separate commands:
uv add "asdf @ git+https://github.com/encode/httpx" --tag 0.24.1
uv add 'asdf > 0.2.0'
Note:
uv add
does not currently support uv add 'asdf @ git+https://github.com/encode/httpx@0.24.1'
, you must either use the --tag
flag or the --raw-sources
flag.uv pip
install allows, uv pip install 'asdf @ git+https://github.com/encode/httpx@0.24.1'
this is valid.pip install 'asdf @ git+https://github.com/encode/httpx@0.24.1'
will error with: has inconsistent name: expected 'asdf', but metadata has 'httpx'
Based on my understanding, if the --git
flag is used, we simply rewrite the requirements
from --git
and the [package]
as needed (similar to how cargo add
works, although cargo add
doesn't currently allow specifying a git URL with a version).
e.g.
uv add [<package>] --git <url>
Unlike
uv add <git-url>
the user should not have to include agit+
prefix.Part of https://github.com/astral-sh/uv/issues/5381