Add support for local directories with --index-url (#4226)

## Summary

Closes #4078.
This commit is contained in:
Charlie Marsh 2024-06-10 19:27:04 -07:00 committed by GitHub
parent f296ef08d6
commit 656fc427b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 219 additions and 31 deletions

View file

@ -124,6 +124,26 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
}
};
// If the URL is a file URL, use the local path directly.
if url.scheme() == "file" {
let path = url
.to_file_path()
.map_err(|()| Error::NonFileUrl(url.clone()))?;
return self
.archive(
source,
&PathSourceUrl {
url: &url,
path: Cow::Owned(path),
},
&cache_shard,
tags,
hashes,
)
.boxed_local()
.await;
}
self.url(
source,
&dist.file.filename,
@ -281,6 +301,25 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
}
};
// If the URL is a file URL, use the local path directly.
if url.scheme() == "file" {
let path = url
.to_file_path()
.map_err(|()| Error::NonFileUrl(url.clone()))?;
return self
.archive_metadata(
source,
&PathSourceUrl {
url: &url,
path: Cow::Owned(path),
},
&cache_shard,
hashes,
)
.boxed_local()
.await;
}
self.url_metadata(
source,
&dist.file.filename,