mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Respect cached local --find-links
in install plan (#2907)
## Summary I think this is kind of just an oversight. If a wheel is available via `--find-links`, and the index is "local", we never find it in the cache. ## Test Plan `cargo test`
This commit is contained in:
parent
31a67f539f
commit
134810c547
3 changed files with 53 additions and 3 deletions
|
@ -150,10 +150,9 @@ impl<'a, Context: BuildContext + Send + Sync> DistributionDatabase<'a, Context>
|
|||
Url::parse(url).map_err(|err| Error::Url(url.clone(), err))?
|
||||
}
|
||||
FileLocation::Path(path) => {
|
||||
let url = Url::from_file_path(path).expect("path is absolute");
|
||||
let cache_entry = self.build_context.cache().entry(
|
||||
CacheBucket::Wheels,
|
||||
WheelCache::Url(&url).wheel_dir(wheel.name().as_ref()),
|
||||
WheelCache::Index(&wheel.index).wheel_dir(wheel.name().as_ref()),
|
||||
wheel.filename.stem(),
|
||||
);
|
||||
return self
|
||||
|
|
|
@ -83,7 +83,10 @@ impl<'a> RegistryWheelIndex<'a> {
|
|||
let flat_index_urls: Vec<IndexUrl> = index_locations
|
||||
.flat_index()
|
||||
.filter_map(|flat_index| match flat_index {
|
||||
FlatIndexLocation::Path(_) => None,
|
||||
FlatIndexLocation::Path(path) => {
|
||||
let path = fs_err::canonicalize(path).ok()?;
|
||||
Some(IndexUrl::Url(VerbatimUrl::from_path(path)))
|
||||
}
|
||||
FlatIndexLocation::Url(url) => {
|
||||
Some(IndexUrl::Url(VerbatimUrl::unknown(url.clone())))
|
||||
}
|
||||
|
|
|
@ -2575,6 +2575,54 @@ fn find_links_offline_no_match() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Sync using `--find-links` with a local directory. Ensure that cached wheels are reused.
|
||||
#[test]
|
||||
fn find_links_cache() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let requirements_txt = context.temp_dir.child("requirements.txt");
|
||||
requirements_txt.write_str(indoc! {r"
|
||||
tqdm
|
||||
"})?;
|
||||
|
||||
// Install `tqdm`.
|
||||
uv_snapshot!(context.filters(), command(&context)
|
||||
.arg("requirements.txt")
|
||||
.arg("--find-links")
|
||||
.arg(context.workspace_root.join("scripts/links/")), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
Downloaded 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ tqdm==1000.0.0
|
||||
"###
|
||||
);
|
||||
|
||||
// Reinstall `tqdm` with `--reinstall`. Ensure that the wheel is reused.
|
||||
uv_snapshot!(context.filters(), command(&context)
|
||||
.arg("requirements.txt")
|
||||
.arg("--reinstall")
|
||||
.arg("--find-links")
|
||||
.arg(context.workspace_root.join("scripts/links/")), @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Uninstalled 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
- tqdm==1000.0.0
|
||||
+ tqdm==1000.0.0
|
||||
"###
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Install without network access via the `--offline` flag.
|
||||
#[test]
|
||||
fn offline() -> Result<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue