From 25cde888ae18bbf3bdc604117644f5a7484e0bfb Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 24 Jun 2024 19:32:45 -0400 Subject: [PATCH] Rename `SitePackages::from_environment` for clarity (#4497) --- crates/uv-dispatch/src/lib.rs | 2 +- crates/uv-installer/src/site_packages.rs | 2 +- crates/uv/src/commands/pip/check.rs | 2 +- crates/uv/src/commands/pip/freeze.rs | 2 +- crates/uv/src/commands/pip/install.rs | 2 +- crates/uv/src/commands/pip/list.rs | 2 +- crates/uv/src/commands/pip/operations.rs | 2 +- crates/uv/src/commands/pip/show.rs | 2 +- crates/uv/src/commands/pip/sync.rs | 2 +- crates/uv/src/commands/pip/tree.rs | 2 +- crates/uv/src/commands/pip/uninstall.rs | 2 +- crates/uv/src/commands/project/mod.rs | 2 +- crates/uv/src/commands/project/sync.rs | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index 412902008..47a62c3e6 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -195,7 +195,7 @@ impl<'a> BuildContext for BuildDispatch<'a> { let tags = self.interpreter.tags()?; // Determine the set of installed packages. - let site_packages = SitePackages::from_executable(venv)?; + let site_packages = SitePackages::from_environment(venv)?; let requirements = resolution.requirements().collect::>(); diff --git a/crates/uv-installer/src/site_packages.rs b/crates/uv-installer/src/site_packages.rs index ac165f63d..a116c2182 100644 --- a/crates/uv-installer/src/site_packages.rs +++ b/crates/uv-installer/src/site_packages.rs @@ -38,7 +38,7 @@ pub struct SitePackages { impl SitePackages { /// Build an index of installed packages from the given Python executable. - pub fn from_executable(venv: &PythonEnvironment) -> Result { + pub fn from_environment(venv: &PythonEnvironment) -> Result { let mut distributions: Vec> = Vec::new(); let mut by_name = FxHashMap::default(); let mut by_url = FxHashMap::default(); diff --git a/crates/uv/src/commands/pip/check.rs b/crates/uv/src/commands/pip/check.rs index c97e9cb99..4fc7f84a0 100644 --- a/crates/uv/src/commands/pip/check.rs +++ b/crates/uv/src/commands/pip/check.rs @@ -39,7 +39,7 @@ pub(crate) fn pip_check( ); // Build the installed index. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; let packages: Vec<&InstalledDist> = site_packages.iter().collect(); let s = if packages.len() == 1 { "" } else { "s" }; diff --git a/crates/uv/src/commands/pip/freeze.rs b/crates/uv/src/commands/pip/freeze.rs index 68ec0e9b2..e4fcd3ed4 100644 --- a/crates/uv/src/commands/pip/freeze.rs +++ b/crates/uv/src/commands/pip/freeze.rs @@ -39,7 +39,7 @@ pub(crate) fn pip_freeze( ); // Build the installed index. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; for dist in site_packages .iter() .filter(|dist| !(exclude_editable && dist.is_editable())) diff --git a/crates/uv/src/commands/pip/install.rs b/crates/uv/src/commands/pip/install.rs index 37de95ccf..6fd68a7e4 100644 --- a/crates/uv/src/commands/pip/install.rs +++ b/crates/uv/src/commands/pip/install.rs @@ -173,7 +173,7 @@ pub(crate) async fn pip_install( let _lock = environment.lock()?; // Determine the set of installed packages. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; // Check if the current environment satisfies the requirements. // Ideally, the resolver would be fast enough to let us remove this check. But right now, for large environments, diff --git a/crates/uv/src/commands/pip/list.rs b/crates/uv/src/commands/pip/list.rs index cd2fc8a74..d5b670644 100644 --- a/crates/uv/src/commands/pip/list.rs +++ b/crates/uv/src/commands/pip/list.rs @@ -49,7 +49,7 @@ pub(crate) fn pip_list( ); // Build the installed index. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; // Filter if `--editable` is specified; always sort by name. let results = site_packages diff --git a/crates/uv/src/commands/pip/operations.rs b/crates/uv/src/commands/pip/operations.rs index e7f0a32c2..f13a212d9 100644 --- a/crates/uv/src/commands/pip/operations.rs +++ b/crates/uv/src/commands/pip/operations.rs @@ -694,7 +694,7 @@ pub(crate) fn diagnose_environment( venv: &PythonEnvironment, printer: Printer, ) -> Result<(), Error> { - let site_packages = SitePackages::from_executable(venv)?; + let site_packages = SitePackages::from_environment(venv)?; for diagnostic in site_packages.diagnostics()? { // Only surface diagnostics that are "relevant" to the current resolution. if resolution diff --git a/crates/uv/src/commands/pip/show.rs b/crates/uv/src/commands/pip/show.rs index e284ca522..992c918b6 100644 --- a/crates/uv/src/commands/pip/show.rs +++ b/crates/uv/src/commands/pip/show.rs @@ -54,7 +54,7 @@ pub(crate) fn pip_show( ); // Build the installed index. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; // Determine the markers to use for resolution. let markers = environment.interpreter().markers(); diff --git a/crates/uv/src/commands/pip/sync.rs b/crates/uv/src/commands/pip/sync.rs index b41694708..01bc3b65b 100644 --- a/crates/uv/src/commands/pip/sync.rs +++ b/crates/uv/src/commands/pip/sync.rs @@ -256,7 +256,7 @@ pub(crate) async fn pip_sync( ); // Determine the set of installed packages. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; let options = OptionsBuilder::new() .resolution_mode(resolution_mode) diff --git a/crates/uv/src/commands/pip/tree.rs b/crates/uv/src/commands/pip/tree.rs index 77c39c50f..e4424e58a 100644 --- a/crates/uv/src/commands/pip/tree.rs +++ b/crates/uv/src/commands/pip/tree.rs @@ -42,7 +42,7 @@ pub(crate) fn pip_tree( ); // Build the installed index. - let site_packages = SitePackages::from_executable(&environment)?; + let site_packages = SitePackages::from_environment(&environment)?; let rendered_tree = DisplayDependencyGraph::new(&site_packages, no_dedupe) .render() diff --git a/crates/uv/src/commands/pip/uninstall.rs b/crates/uv/src/commands/pip/uninstall.rs index e15988825..a19c91b9b 100644 --- a/crates/uv/src/commands/pip/uninstall.rs +++ b/crates/uv/src/commands/pip/uninstall.rs @@ -104,7 +104,7 @@ pub(crate) async fn pip_uninstall( let _lock = environment.lock()?; // Index the current `site-packages` directory. - let site_packages = uv_installer::SitePackages::from_executable(&environment)?; + let site_packages = uv_installer::SitePackages::from_environment(&environment)?; // Partition the requirements into named and unnamed requirements. let (named, unnamed): (Vec, Vec>) = spec diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 0729bf6fc..c06003f64 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -318,7 +318,7 @@ pub(crate) async fn update_environment( RequirementsSpecification::from_sources(requirements, &[], &[], &client_builder).await?; // Check if the current environment satisfies the requirements - let site_packages = SitePackages::from_executable(&venv)?; + let site_packages = SitePackages::from_environment(&venv)?; if spec.source_trees.is_empty() { match site_packages.satisfies(&spec.requirements, &spec.constraints)? { // If the requirements are already satisfied, we're done. diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 4c7ed23cb..c8303cdc4 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -191,7 +191,7 @@ pub(super) async fn do_sync( preview, ); - let site_packages = SitePackages::from_executable(venv)?; + let site_packages = SitePackages::from_environment(venv)?; // Sync the environment. pip::operations::install(