Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove empty folders on python uninstall #512

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,6 @@ async fn update_python_distributions(
.dist_info
.strip_prefix(site_package_path)
.expect("the dist-info path must be a sub-path of the site-packages path");
rip::uninstall::uninstall_distribution(&prefix.root().join(site_package_path), relative_dist_info)
.into_diagnostic()
.with_context(|| format!("could not uninstall python package {}-{}. Manually remove the `.pixi/env` folder and try again.", &python_distribution.name, &python_distribution.version))?;

// HACK: Also remove the HASH file that pixi writes. Ignore the error if its there. We
// should probably actually add this file to the RECORD.
Expand All @@ -269,6 +266,10 @@ async fn update_python_distributions(
.join(&python_distribution.dist_info)
.join("HASH"),
);

rip::uninstall::uninstall_distribution(&prefix.root().join(site_package_path), relative_dist_info)
.into_diagnostic()
.with_context(|| format!("could not uninstall python package {}-{}. Manually remove the `.pixi/env` folder and try again.", &python_distribution.name, &python_distribution.version))?;
}
}

Expand Down Expand Up @@ -534,14 +535,15 @@ fn remove_old_python_distributions(
.dist_info
.strip_prefix(site_package_path)
.expect("the dist-info path must be a sub-path of the site-packages path");
rip::uninstall::uninstall_distribution(&prefix.root().join(site_package_path), relative_dist_info)
.into_diagnostic()
.with_context(|| format!("could not uninstall python package {}-{}. Manually remove the `.pixi/env` folder and try again.", &python_package.name, &python_package.version))?;

// HACK: Also remove the HASH file that pixi writes. Ignore the error if its there. We
// should probably actually add this file to the RECORD.
let _ = std::fs::remove_file(prefix.root().join(&python_package.dist_info).join("HASH"));

rip::uninstall::uninstall_distribution(&prefix.root().join(site_package_path), relative_dist_info)
ruben-arts marked this conversation as resolved.
Show resolved Hide resolved
.into_diagnostic()
.with_context(|| format!("could not uninstall python package {}-{}. Manually remove the `.pixi/env` folder and try again.", &python_package.name, &python_package.version))?;

pb.inc(1);
}

Expand Down