Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect installed packages in uv run #3603

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/uv/src/commands/project/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -111,6 +111,7 @@ pub(crate) async fn lock(
// Resolve the requirements.
let resolution = project::resolve(
spec,
&EmptyInstalledPackages,
&hasher,
&interpreter,
tags,
Expand Down
8 changes: 4 additions & 4 deletions crates/uv/src/commands/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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 = {
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion crates/uv/src/commands/project/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ async fn update_environment(
// Resolve the requirements.
let resolution = match project::resolve(
spec,
&site_packages,
&hasher,
&interpreter,
tags,
Expand All @@ -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,
Expand Down
Loading