Respect installed packages in `uv run` (#3603)

Closes #3601.
This commit is contained in:
Charlie Marsh 2024-05-15 11:48:32 -04:00 committed by GitHub
parent f7b9ca9533
commit ef068f1c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View File

@ -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,

View File

@ -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<InstalledPackages: InstalledPackagesProvider>(
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));

View File

@ -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,