Skip to content

Commit

Permalink
Retain editable designation for cached wheel installs (#5545)
Browse files Browse the repository at this point in the history
## Summary

The package was being installed as editable, but it wasn't marked as
such in `uv pip list`, as the `direct-url.json` was wrong.

Closes #5543.
  • Loading branch information
charliermarsh authored Jul 29, 2024
1 parent 9af0ae2 commit 51b7e9b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions crates/uv-distribution/src/index/cached_wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ impl CachedWheel {
}
}

/// Convert a [`CachedWheel`] into an editable [`CachedDirectUrlDist`].
pub fn into_editable(self, url: VerbatimUrl) -> CachedDirectUrlDist {
CachedDirectUrlDist {
filename: self.filename,
url,
path: self.entry.into_path_buf(),
editable: true,
hashes: self.hashes,
}
}

/// Read a cached wheel from a `.http` pointer (e.g., `anyio-4.0.0-py3-none-any.http`).
pub fn from_http_pointer(path: impl AsRef<Path>, cache: &Cache) -> Option<Self> {
let path = path.as_ref();
Expand Down
6 changes: 5 additions & 1 deletion crates/uv-installer/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ impl<'a> Planner<'a> {
// Find the most-compatible wheel from the cache, since we don't know
// the filename in advance.
if let Some(wheel) = built_index.directory(&sdist)? {
let cached_dist = wheel.into_url_dist(url.clone());
let cached_dist = if *editable {
wheel.into_editable(url.clone())
} else {
wheel.into_url_dist(url.clone())
};
debug!("Directory source requirement already cached: {cached_dist}");
cached.push(CachedDist::Url(cached_dist));
continue;
Expand Down

0 comments on commit 51b7e9b

Please sign in to comment.