Avoid infinite loop for cyclic installs (#4633)

## Summary

Closes https://github.com/astral-sh/uv/issues/4629.

## Test Plan

Run `uv sync` with:

```toml
[project]
name = "foo"
version = "0.1.0"
requires-python = ">=3.9"
dependencies = ["poetry"]
```
This commit is contained in:
Charlie Marsh 2024-06-28 16:15:28 -04:00 committed by GitHub
parent 22ce8fdf4b
commit 164160da34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 192 additions and 4 deletions

View file

@ -325,6 +325,7 @@ impl Lock {
dev: &[GroupName],
) -> Result<Resolution, LockError> {
let mut queue: VecDeque<(&Distribution, Option<&ExtraName>)> = VecDeque::new();
let mut seen = FxHashSet::default();
// Add the root distribution to the queue.
let root = self
@ -362,16 +363,17 @@ impl Lock {
}),
))
};
for dep in deps {
if dep
.marker
.as_ref()
.map_or(true, |marker| marker.evaluate(marker_env, &[]))
{
let dep_dist = self.find_by_id(&dep.distribution_id);
let dep_extra = dep.extra.as_ref();
queue.push_back((dep_dist, dep_extra));
if seen.insert((&dep.distribution_id, dep.extra.as_ref())) {
let dep_dist = self.find_by_id(&dep.distribution_id);
let dep_extra = dep.extra.as_ref();
queue.push_back((dep_dist, dep_extra));
}
}
}
let name = dist.id.name.clone();