mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-17 02:52:45 +00:00
Add an editable index to the site-packages registry (#671)
This PR modifies `SitePackages` to store all distributions in a flat vector, and maintain two indexes (hash maps) from "per-element data for an element in the vector" to "index of that element". This enables us to maintain a map on both package name and editable URL.
This commit is contained in:
parent
08edd173db
commit
00e1c33af4
5 changed files with 129 additions and 54 deletions
|
|
@ -3,6 +3,7 @@ use std::str::FromStr;
|
|||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use fs_err as fs;
|
||||
use url::Url;
|
||||
|
||||
use pep440_rs::Version;
|
||||
use puffin_normalize::PackageName;
|
||||
|
|
@ -140,4 +141,15 @@ impl InstalledDist {
|
|||
Metadata21::parse(&contents)
|
||||
.with_context(|| format!("Failed to parse METADATA file at: {}", path.display()))
|
||||
}
|
||||
|
||||
/// Return the [`Url`] of the distribution, if it is editable.
|
||||
pub fn editable(&self) -> Option<&Url> {
|
||||
match self {
|
||||
Self::Url(InstalledDirectUrlDist {
|
||||
url: DirectUrl::LocalDirectory { url, dir_info },
|
||||
..
|
||||
}) if dir_info.editable == Some(true) => Some(url),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue