Use Simplified instead of Normalized for path prefix stripping (#2071)

## Summary

This directly matches the naming of the `dunce` methods.
This commit is contained in:
Charlie Marsh 2024-02-28 20:44:50 -05:00 committed by GitHub
parent f315d07133
commit ef15098288
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 129 additions and 129 deletions

View file

@ -14,7 +14,7 @@ use distribution_filename::WheelFilename;
use pep440_rs::Version;
use platform_host::{Arch, Os};
pub use uninstall::{uninstall_wheel, Uninstall};
use uv_fs::Normalized;
use uv_fs::Simplified;
use uv_normalize::PackageName;
pub mod linker;
@ -47,7 +47,7 @@ pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),
/// Custom error type to add a path to error reading a file from a zip
#[error("Failed to reflink {} to {}", from.normalized_display(), to.normalized_display())]
#[error("Failed to reflink {} to {}", from.simplified_display(), to.simplified_display())]
Reflink {
from: PathBuf,
to: PathBuf,
@ -88,7 +88,7 @@ pub enum Error {
DirectUrlJson(#[from] serde_json::Error),
#[error("No .dist-info directory found")]
MissingDistInfo,
#[error("Cannot uninstall package; RECORD file not found at: {}", _0.normalized_display())]
#[error("Cannot uninstall package; RECORD file not found at: {}", _0.simplified_display())]
MissingRecord(PathBuf),
#[error("Multiple .dist-info directories found: {0}")]
MultipleDistInfo(String),

View file

@ -15,7 +15,7 @@ use zip::write::FileOptions;
use zip::ZipWriter;
use pypi_types::DirectUrl;
use uv_fs::Normalized;
use uv_fs::Simplified;
use crate::record::RecordEntry;
use crate::script::Script;
@ -115,7 +115,7 @@ fn copy_and_hash(reader: &mut impl Read, writer: &mut impl Write) -> io::Result<
}
fn get_shebang(python_executable: impl AsRef<Path>) -> String {
format!("#!{}", python_executable.as_ref().normalized().display())
format!("#!{}", python_executable.as_ref().simplified().display())
}
/// A Windows script is a minimal .exe launcher binary with the python entrypoint script appended as
@ -176,7 +176,7 @@ pub(crate) fn windows_script_launcher(
}
let python = python_executable.as_ref();
let python_path = python.normalized().to_string_lossy();
let python_path = python.simplified().to_string_lossy();
let mut launcher: Vec<u8> = Vec::with_capacity(launcher_bin.len() + payload.len());
launcher.extend_from_slice(launcher_bin);
@ -222,7 +222,7 @@ pub(crate) fn write_script_entrypoints(
io::ErrorKind::Other,
format!(
"Could not find relative path for: {}",
entrypoint_absolute.normalized_display()
entrypoint_absolute.simplified_display()
),
))
})?;
@ -344,8 +344,8 @@ pub(crate) fn relative_to(path: &Path, base: &Path) -> Result<PathBuf, Error> {
io::ErrorKind::Other,
format!(
"Trivial strip failed: {} vs. {}",
path.normalized_display(),
base.normalized_display()
path.simplified_display(),
base.simplified_display()
),
))
})?;
@ -387,8 +387,8 @@ pub(crate) fn move_folder_recorded(
.ok_or_else(|| {
Error::RecordFile(format!(
"Could not find entry for {} ({})",
relative_to_site_packages.normalized_display(),
src.normalized_display()
relative_to_site_packages.simplified_display(),
src.simplified_display()
))
})?;
entry.path = relative_to(&target, site_packages)?.display().to_string();
@ -460,8 +460,8 @@ fn install_script(
// This should be possible to occur at this point, but filesystems and such
Error::RecordFile(format!(
"Could not find entry for {} ({})",
relative_to_site_packages.normalized_display(),
path.normalized_display()
relative_to_site_packages.simplified_display(),
path.simplified_display()
))
})?;
entry.path = target_path.display().to_string();