Use portable paths when serializing sources (#7504)

## Summary

Closes https://github.com/astral-sh/uv/issues/7493.
This commit is contained in:
Charlie Marsh 2024-09-18 14:51:14 -04:00 committed by GitHub
parent 1379b530f6
commit e36cc99b0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 70 additions and 36 deletions

View file

@ -88,20 +88,20 @@ impl LoweredRequirement {
if matches!(requirement.version_or_url, Some(VersionOrUrl::Url(_))) {
return Err(LoweringError::ConflictingUrls);
}
git_source(&git, subdirectory, rev, tag, branch)?
git_source(&git, subdirectory.map(PathBuf::from), rev, tag, branch)?
}
Source::Url { url, subdirectory } => {
if matches!(requirement.version_or_url, Some(VersionOrUrl::Url(_))) {
return Err(LoweringError::ConflictingUrls);
}
url_source(url, subdirectory)?
url_source(url, subdirectory.map(PathBuf::from))?
}
Source::Path { path, editable } => {
if matches!(requirement.version_or_url, Some(VersionOrUrl::Url(_))) {
return Err(LoweringError::ConflictingUrls);
}
path_source(
path,
PathBuf::from(path),
origin,
project_dir,
workspace.install_path(),
@ -203,19 +203,25 @@ impl LoweredRequirement {
if matches!(requirement.version_or_url, Some(VersionOrUrl::Url(_))) {
return Err(LoweringError::ConflictingUrls);
}
git_source(&git, subdirectory, rev, tag, branch)?
git_source(&git, subdirectory.map(PathBuf::from), rev, tag, branch)?
}
Source::Url { url, subdirectory } => {
if matches!(requirement.version_or_url, Some(VersionOrUrl::Url(_))) {
return Err(LoweringError::ConflictingUrls);
}
url_source(url, subdirectory)?
url_source(url, subdirectory.map(PathBuf::from))?
}
Source::Path { path, editable } => {
if matches!(requirement.version_or_url, Some(VersionOrUrl::Url(_))) {
return Err(LoweringError::ConflictingUrls);
}
path_source(path, Origin::Project, dir, dir, editable.unwrap_or(false))?
path_source(
PathBuf::from(path),
Origin::Project,
dir,
dir,
editable.unwrap_or(false),
)?
}
Source::Registry { index } => registry_source(&requirement, index)?,
Source::Workspace { .. } => {