mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Use asterisk for dependency cycles in uv pip tree
(#4626)
## Summary Use an asterisk to indicate dependency cycles, along with de-duplicated packages. Purely an aesthetic change.
This commit is contained in:
parent
a444e59668
commit
72438ef5bb
2 changed files with 13 additions and 18 deletions
|
@ -57,14 +57,12 @@ pub(crate) fn pip_tree(
|
||||||
.join("\n");
|
.join("\n");
|
||||||
writeln!(printer.stdout(), "{rendered_tree}").unwrap();
|
writeln!(printer.stdout(), "{rendered_tree}").unwrap();
|
||||||
if rendered_tree.contains('*') {
|
if rendered_tree.contains('*') {
|
||||||
writeln!(
|
let message = if no_dedupe {
|
||||||
printer.stdout(),
|
"(*) Package tree is a cycle and cannot be shown".italic()
|
||||||
"{}",
|
} else {
|
||||||
"(*) Package tree already displayed".italic()
|
"(*) Package tree already displayed".italic()
|
||||||
)?;
|
};
|
||||||
}
|
writeln!(printer.stdout(), "{message}")?;
|
||||||
if rendered_tree.contains('#') {
|
|
||||||
writeln!(printer.stdout(), "{}", "(#) Dependency cycle".italic())?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that the environment is consistent.
|
// Validate that the environment is consistent.
|
||||||
|
@ -176,13 +174,10 @@ impl<'a> DisplayDependencyGraph<'a> {
|
||||||
let is_visited = visited.contains(&package_name);
|
let is_visited = visited.contains(&package_name);
|
||||||
let line = format!("{} v{}", package_name, installed_dist.version());
|
let line = format!("{} v{}", package_name, installed_dist.version());
|
||||||
|
|
||||||
if path.contains(&package_name) {
|
// Skip the traversal if
|
||||||
return vec![format!("{} (#)", line)];
|
// 1. the package is in the current traversal path (i.e. a dependency cycle)
|
||||||
}
|
// 2. if the package has been visited and de-duplication is enabled (default)
|
||||||
|
if path.contains(&package_name) || (is_visited && !self.no_dedupe) {
|
||||||
// If the package has been visited and de-duplication is enabled (default),
|
|
||||||
// skip the traversal.
|
|
||||||
if is_visited && !self.no_dedupe {
|
|
||||||
return vec![format!("{} (*)", line)];
|
return vec![format!("{} (*)", line)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -623,8 +623,8 @@ fn cyclic_dependency() {
|
||||||
uv-cyclic-dependencies-c v0.1.0
|
uv-cyclic-dependencies-c v0.1.0
|
||||||
└── uv-cyclic-dependencies-a v0.1.0
|
└── uv-cyclic-dependencies-a v0.1.0
|
||||||
└── uv-cyclic-dependencies-b v0.1.0
|
└── uv-cyclic-dependencies-b v0.1.0
|
||||||
└── uv-cyclic-dependencies-a v0.1.0 (#)
|
└── uv-cyclic-dependencies-a v0.1.0 (*)
|
||||||
(#) Dependency cycle
|
(*) Package tree already displayed
|
||||||
|
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
"###
|
"###
|
||||||
|
@ -906,8 +906,8 @@ fn no_dedupe_and_cycle() {
|
||||||
uv-cyclic-dependencies-c v0.1.0
|
uv-cyclic-dependencies-c v0.1.0
|
||||||
└── uv-cyclic-dependencies-a v0.1.0
|
└── uv-cyclic-dependencies-a v0.1.0
|
||||||
└── uv-cyclic-dependencies-b v0.1.0
|
└── uv-cyclic-dependencies-b v0.1.0
|
||||||
└── uv-cyclic-dependencies-a v0.1.0 (#)
|
└── uv-cyclic-dependencies-a v0.1.0 (*)
|
||||||
(#) Dependency cycle
|
(*) Package tree is a cycle and cannot be shown
|
||||||
|
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
"###
|
"###
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue