mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
fix the issue with pruning the last package in pip tree
(#4652)
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary resolves https://github.com/astral-sh/uv/issues/4651 (pruning needs to happen at the parent level so that the number of children being used to figure out the output is correct) <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan added a test that would've caught this bug 🌵 <!-- How was it tested? -->
This commit is contained in:
parent
13b0beb56f
commit
7cc4565b5b
2 changed files with 47 additions and 6 deletions
|
@ -165,11 +165,6 @@ impl<'a> DisplayDependencyGraph<'a> {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Short-circuit if the current package is given in the prune list.
|
|
||||||
if self.prune.contains(installed_dist.name()) {
|
|
||||||
return Vec::new();
|
|
||||||
}
|
|
||||||
|
|
||||||
let package_name = installed_dist.name().to_string();
|
let package_name = installed_dist.name().to_string();
|
||||||
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());
|
||||||
|
@ -185,7 +180,10 @@ impl<'a> DisplayDependencyGraph<'a> {
|
||||||
|
|
||||||
path.push(package_name.clone());
|
path.push(package_name.clone());
|
||||||
visited.insert(package_name.clone());
|
visited.insert(package_name.clone());
|
||||||
let required_packages = required_with_no_extra(installed_dist, self.markers);
|
let required_packages = required_with_no_extra(installed_dist, self.markers)
|
||||||
|
.into_iter()
|
||||||
|
.filter(|p| !self.prune.contains(&p.name))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
for (index, required_package) in required_packages.iter().enumerate() {
|
for (index, required_package) in required_packages.iter().enumerate() {
|
||||||
// Skip if the current package is not one of the installed distributions.
|
// Skip if the current package is not one of the installed distributions.
|
||||||
if !self
|
if !self
|
||||||
|
|
|
@ -31,6 +31,49 @@ fn no_package() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn prune_last_in_the_subgroup() {
|
||||||
|
let context = TestContext::new("3.12");
|
||||||
|
|
||||||
|
let requirements_txt = context.temp_dir.child("requirements.txt");
|
||||||
|
requirements_txt.write_str("requests==2.31.0").unwrap();
|
||||||
|
|
||||||
|
uv_snapshot!(context
|
||||||
|
.pip_install()
|
||||||
|
.arg("-r")
|
||||||
|
.arg("requirements.txt")
|
||||||
|
.arg("--strict"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
Resolved 5 packages in [TIME]
|
||||||
|
Prepared 5 packages in [TIME]
|
||||||
|
Installed 5 packages in [TIME]
|
||||||
|
+ certifi==2024.2.2
|
||||||
|
+ charset-normalizer==3.3.2
|
||||||
|
+ idna==3.6
|
||||||
|
+ requests==2.31.0
|
||||||
|
+ urllib3==2.2.1
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
|
||||||
|
context.assert_command("import requests").success();
|
||||||
|
uv_snapshot!(context.filters(), tree_command(&context).arg("--prune").arg("certifi"), @r###"
|
||||||
|
success: true
|
||||||
|
exit_code: 0
|
||||||
|
----- stdout -----
|
||||||
|
requests v2.31.0
|
||||||
|
├── charset-normalizer v3.3.2
|
||||||
|
├── idna v3.6
|
||||||
|
└── urllib3 v2.2.1
|
||||||
|
|
||||||
|
----- stderr -----
|
||||||
|
"###
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn single_package() {
|
fn single_package() {
|
||||||
let context = TestContext::new("3.12");
|
let context = TestContext::new("3.12");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue