Skip to content

Commit

Permalink
Treat missing top_level.txt as non-fatal (#6881)
Browse files Browse the repository at this point in the history
## Summary

Closes #6872.
  • Loading branch information
charliermarsh authored Aug 30, 2024
1 parent 0510842 commit fa14983
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
10 changes: 9 additions & 1 deletion crates/uv/src/commands/pip/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,15 @@ pub(crate) async fn install(
install_wheel_rs::Error::MissingRecord(_),
)) => {
warn_user!(
"Failed to uninstall package at {} due to missing RECORD file. Installation may result in an incomplete environment.",
"Failed to uninstall package at {} due to missing `RECORD` file. Installation may result in an incomplete environment.",
dist_info.path().user_display().cyan(),
);
}
Err(uv_installer::UninstallError::Uninstall(
install_wheel_rs::Error::MissingTopLevel(_),
)) => {
warn_user!(
"Failed to uninstall package at {} due to missing `top-level.txt` file. Installation may result in an incomplete environment.",
dist_info.path().user_display().cyan(),
);
}
Expand Down
39 changes: 38 additions & 1 deletion crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ fn reinstall_incomplete() -> Result<()> {
----- stderr -----
Resolved 3 packages in [TIME]
Prepared 1 package in [TIME]
warning: Failed to uninstall package at [SITE_PACKAGES]/anyio-3.7.0.dist-info due to missing RECORD file. Installation may result in an incomplete environment.
warning: Failed to uninstall package at [SITE_PACKAGES]/anyio-3.7.0.dist-info due to missing `RECORD` file. Installation may result in an incomplete environment.
Uninstalled 1 package in [TIME]
Installed 1 package in [TIME]
- anyio==3.7.0
Expand Down Expand Up @@ -6455,3 +6455,40 @@ fn stale_egg_info() -> Result<()> {

Ok(())
}

/// `suds-community` has an incorrect layout whereby the wheel includes `suds_community.egg-info` at
/// the top-level. We're then under the impression that `suds` is installed twice, but when we go to
/// uninstall the second "version", we can't find the `egg-info` directory.
#[test]
fn missing_top_level() {
let context = TestContext::new("3.12");

uv_snapshot!(context.filters(), context.pip_install()
.arg("suds-community==0.8.5"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ suds-community==0.8.5
"###
);

uv_snapshot!(context.filters(), context.pip_install()
.arg("suds-community==0.8.5"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
warning: Failed to uninstall package at [SITE_PACKAGES]/suds_community.egg-info due to missing `top-level.txt` file. Installation may result in an incomplete environment.
Uninstalled 2 packages in [TIME]
Installed 1 package in [TIME]
~ suds-community==0.8.5
"###
);
}

0 comments on commit fa14983

Please sign in to comment.