Delete any directories listed in the RECORD file (#394)

## Summary

It looks like, when you install `pip`, it includes a bunch of
`__pycache__` directories in the RECORD file (although these directories
don't exist until you run `pip`). Our uninstaller assumed that the
RECORD file only contained _files_.

Closes https://github.com/astral-sh/puffin/issues/389.
This commit is contained in:
Charlie Marsh 2023-11-10 10:17:52 -08:00 committed by GitHub
parent 6a15950cb5
commit b3edf7c2b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 20 deletions

View File

@ -30,13 +30,19 @@ pub fn uninstall_wheel(dist_info: &Path) -> Result<Uninstall, Error> {
Ok(()) => {
debug!("Removed file: {}", path.display());
file_count += 1;
if let Some(parent) = path.parent() {
visited.insert(normalize_path(parent));
}
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(err) => return Err(err.into()),
}
if let Some(parent) = path.parent() {
visited.insert(normalize_path(parent));
Err(err) => match fs::remove_dir_all(&path) {
Ok(()) => {
debug!("Removed directory: {}", path.display());
dir_count += 1;
}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(_) => return Err(err.into()),
},
}
}

View File

@ -8,9 +8,9 @@ info:
- "--python-version"
- py312
- "--cache-dir"
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpbKzceW
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpOMYCx3
env:
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpZkKRNz/.venv
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpPNeQK1/.venv
---
success: true
exit_code: 0
@ -26,7 +26,7 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black
----- stderr -----

View File

@ -8,9 +8,9 @@ info:
- "--python-version"
- py37
- "--cache-dir"
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpQwHoBA
- /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpzwzUVe
env:
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmp1TmUIW/.venv
VIRTUAL_ENV: /var/folders/nt/6gf2v7_s3k13zq_t3944rwz40000gn/T/.tmpqFv4YL/.venv
---
success: true
exit_code: 0
@ -28,7 +28,7 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black
tomli==2.0.1
# via black

View File

@ -11,6 +11,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black

View File

@ -12,6 +12,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black

View File

@ -11,6 +11,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black

View File

@ -11,6 +11,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black

View File

@ -9,7 +9,7 @@ mypy-extensions==1.0.0
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black
tomli==2.0.1
# via black

View File

@ -11,6 +11,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black

View File

@ -11,6 +11,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black

View File

@ -11,7 +11,7 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black
tomli==2.0.1
# via black

View File

@ -11,6 +11,6 @@ packaging==23.2
# via black
pathspec==0.11.2
# via black
platformdirs==3.11.0
platformdirs==4.0.0
# via black