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:
@@ -1,4 +1,6 @@
|
||||
use anyhow::Result;
|
||||
use distribution_types::Metadata;
|
||||
use itertools::Itertools;
|
||||
use tracing::debug;
|
||||
|
||||
use platform_host::Platform;
|
||||
@@ -21,7 +23,10 @@ pub(crate) fn freeze(cache: &Cache, _printer: Printer) -> Result<ExitStatus> {
|
||||
|
||||
// Build the installed index.
|
||||
let site_packages = SitePackages::from_executable(&python)?;
|
||||
for dist in site_packages.distributions() {
|
||||
for dist in site_packages
|
||||
.iter()
|
||||
.sorted_unstable_by(|a, b| a.name().cmp(b.name()))
|
||||
{
|
||||
#[allow(clippy::print_stdout)]
|
||||
{
|
||||
println!("{dist}");
|
||||
|
||||
@@ -78,11 +78,7 @@ pub(crate) async fn pip_uninstall(
|
||||
|
||||
// Identify all editables that are installed.
|
||||
for editable in &editables {
|
||||
if let Some(distribution) = site_packages
|
||||
.editables()
|
||||
.find(|(_dist, url, _dir_info)| url == editable)
|
||||
.map(|(dist, _url, _dir_info)| dist)
|
||||
{
|
||||
if let Some(distribution) = site_packages.get_editable(editable) {
|
||||
distributions.push(distribution);
|
||||
} else {
|
||||
writeln!(
|
||||
|
||||
Reference in New Issue
Block a user