From 8f236f3f5d2c89a976d736b805e635b10616af0d Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 15 May 2024 10:33:14 -0400 Subject: [PATCH] Respect installed packages in uv run --- crates/uv/src/commands/project/lock.rs | 3 ++- crates/uv/src/commands/project/mod.rs | 8 ++++---- crates/uv/src/commands/project/run.rs | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 1ddd84da185c..081d9e620330 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -11,7 +11,7 @@ use uv_configuration::{ use uv_dispatch::BuildDispatch; use uv_requirements::{ExtrasSpecification, RequirementsSpecification}; use uv_resolver::{FlatIndex, InMemoryIndex, OptionsBuilder}; -use uv_types::{BuildIsolation, HashStrategy, InFlight}; +use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy, InFlight}; use uv_warnings::warn_user; use crate::commands::project::discovery::Project; @@ -111,6 +111,7 @@ pub(crate) async fn lock( // Resolve the requirements. let resolution = project::resolve( spec, + &EmptyInstalledPackages, &hasher, &interpreter, tags, diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 1e5888d71ea1..23b5441a4bc0 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -25,7 +25,7 @@ use uv_resolver::{ Exclusions, FlatIndex, InMemoryIndex, Manifest, Options, PythonRequirement, ResolutionGraph, Resolver, }; -use uv_types::{EmptyInstalledPackages, HashStrategy, InFlight}; +use uv_types::{HashStrategy, InFlight, InstalledPackagesProvider}; use crate::commands::project::discovery::Project; use crate::commands::reporters::{DownloadReporter, InstallReporter, ResolverReporter}; @@ -113,8 +113,9 @@ pub(crate) fn init( /// Resolve a set of requirements, similar to running `pip compile`. #[allow(clippy::too_many_arguments)] -pub(crate) async fn resolve( +pub(crate) async fn resolve( spec: RequirementsSpecification, + installed_packages: &InstalledPackages, hasher: &HashStrategy, interpreter: &Interpreter, tags: &Tags, @@ -135,7 +136,6 @@ pub(crate) async fn resolve( let overrides = Overrides::default(); let python_requirement = PythonRequirement::from_marker_environment(interpreter, markers); let editables = Vec::new(); - let installed_packages = EmptyInstalledPackages; // Resolve the requirements from the provided sources. let requirements = { @@ -206,7 +206,7 @@ pub(crate) async fn resolve( index, hasher, build_dispatch, - &installed_packages, + installed_packages, DistributionDatabase::new(client, build_dispatch, concurrency.downloads), )? .with_reporter(ResolverReporter::from(printer)); diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 7df20e9fa918..9ead77768d18 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -292,6 +292,7 @@ async fn update_environment( // Resolve the requirements. let resolution = match project::resolve( spec, + &site_packages, &hasher, &interpreter, tags, @@ -316,7 +317,7 @@ async fn update_environment( // Sync the environment. project::install( &resolution, - SitePackages::from_executable(&venv)?, + site_packages, &no_binary, link_mode, &index_locations,