mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Flatten requirements eagerly in get_dependencies
(#4430)
Downstack PR: #4515 Upstack PR: #4481
Consider these two cases:
A:
```
werkzeug==2.0.0
werkzeug @ 960bb4017c/Werkzeug-2.0.0-py3-none-any.whl
```
B:
```toml
dependencies = [
"iniconfig == 1.1.1 ; python_version < '3.12'",
"iniconfig @ git+https://github.com/pytest-dev/iniconfig@93f5930e668c0d1ddf4597e38dd0dea4e2665e7a ; python_version >= '3.12'",
]
```
In the first case, `werkzeug==2.0.0` should be overridden by the url. In
the second case `iniconfig == 1.1.1` is in a different fork and must
remain a registry distribution.
That means the conversion from `Requirement` to `PubGrubPackage` is
dependent on the other requirements of the package. We can either look
into the other packages immediately, or we can move the forking before
the conversion to `PubGrubDependencies` instead of after. Either version
requires a flat list of `Requirement`s to use. This refactoring gives us
this list.
I'll add support for both of the above cases in the forking urls branch
before merging this PR. I also have to move constraints over to this.
This commit is contained in:
parent
e242cdf713
commit
f2f48d339e
3 changed files with 230 additions and 283 deletions
|
@ -16,7 +16,11 @@ impl Constraints {
|
|||
constraints
|
||||
.entry(requirement.name.clone())
|
||||
.or_default()
|
||||
.push(requirement);
|
||||
.push(Requirement {
|
||||
// We add and apply constraints independent of their extras.
|
||||
extras: vec![],
|
||||
..requirement
|
||||
});
|
||||
}
|
||||
Self(constraints)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue