mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-21 07:42:05 +00:00
Remove UNC prefixes on Windows (#1086)
## Summary This PR adds a `NormalizedDisplay` trait that we can use for user-facing paths, to strip the UNC prefix on Windows. On other platforms, the implementation is a no-op (vs. `Display`). I audited all usages of `.display()`, and changed any that were user-facing, either via `println!` or `eprintln!`, or by way of being included in error messages. I did _not_ change uses that were only in tests or only went to tracing. Closes https://github.com/astral-sh/puffin/issues/1084.
This commit is contained in:
parent
035cd81ac8
commit
f4939e50a6
23 changed files with 98 additions and 43 deletions
|
@ -18,6 +18,7 @@ distribution-filename = { path = "../distribution-filename", features = ["serde"
|
|||
pep440_rs = { path = "../pep440-rs" }
|
||||
pep508_rs = { path = "../pep508-rs" }
|
||||
platform-tags = { path = "../platform-tags" }
|
||||
puffin-fs = { path = "../puffin-fs" }
|
||||
puffin-git = { path = "../puffin-git", features = ["vendored-openssl"] }
|
||||
puffin-normalize = { path = "../puffin-normalize" }
|
||||
pypi-types = { path = "../pypi-types" }
|
||||
|
|
|
@ -6,6 +6,7 @@ use fs_err as fs;
|
|||
use url::Url;
|
||||
|
||||
use pep440_rs::Version;
|
||||
use puffin_fs::NormalizedDisplay;
|
||||
use puffin_normalize::PackageName;
|
||||
|
||||
use crate::{InstalledMetadata, InstalledVersion, Name};
|
||||
|
@ -102,8 +103,12 @@ impl InstalledDist {
|
|||
pub fn metadata(&self) -> Result<pypi_types::Metadata21> {
|
||||
let path = self.path().join("METADATA");
|
||||
let contents = fs::read(&path)?;
|
||||
pypi_types::Metadata21::parse(&contents)
|
||||
.with_context(|| format!("Failed to parse METADATA file at: {}", path.display()))
|
||||
pypi_types::Metadata21::parse(&contents).with_context(|| {
|
||||
format!(
|
||||
"Failed to parse METADATA file at: {}",
|
||||
path.normalized_display()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the [`Url`] of the distribution, if it is editable.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue