Use a cross-platform representation for relative paths in pip compile (#3804)

## Summary

I haven't tested on Windows yet, but the idea here is that we should use
a portable representation when printing paths.

I decided to limit the scope here to paths that we write to output
files.

Closes https://github.com/astral-sh/uv/issues/3800.
This commit is contained in:
Charlie Marsh
2024-05-23 23:02:42 -04:00
committed by GitHub
parent a7d486bc71
commit 8d566e553d
10 changed files with 75 additions and 26 deletions
+4 -4
View File
@@ -22,17 +22,17 @@ impl std::fmt::Display for SourceAnnotation {
match self {
Self::Requirement(origin) => match origin {
RequirementOrigin::File(path) => {
write!(f, "-r {}", path.user_display())
write!(f, "-r {}", path.portable_display())
}
RequirementOrigin::Project(path, project_name) => {
write!(f, "{project_name} ({})", path.user_display())
write!(f, "{project_name} ({})", path.portable_display())
}
},
Self::Constraint(origin) => {
write!(f, "-c {}", origin.path().user_display())
write!(f, "-c {}", origin.path().portable_display())
}
Self::Override(origin) => {
write!(f, "--override {}", origin.path().user_display())
write!(f, "--override {}", origin.path().portable_display())
}
}
}