Skip to content

Commit

Permalink
Allow sync and update environment methods to take modifications (#11346)
Browse files Browse the repository at this point in the history
## Summary

I have a use-case for an inexact sync here, so putting this up
separately.
  • Loading branch information
charliermarsh authored Feb 9, 2025
1 parent 6dfac45 commit d22a2df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/uv/src/commands/project/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use uv_python::{Interpreter, PythonEnvironment};
use uv_resolver::Installable;

use crate::commands::pip::loggers::{InstallLogger, ResolveLogger};
use crate::commands::pip::operations::Modifications;
use crate::commands::project::install_target::InstallTarget;
use crate::commands::project::{
resolve_environment, sync_environment, EnvironmentSpecification, PlatformState, ProjectError,
Expand Down Expand Up @@ -193,6 +194,7 @@ impl CachedEnvironment {
sync_environment(
venv,
&resolution,
Modifications::Exact,
settings.as_ref().into(),
state,
install,
Expand Down
6 changes: 4 additions & 2 deletions crates/uv/src/commands/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,7 @@ pub(crate) async fn resolve_environment(
pub(crate) async fn sync_environment(
venv: PythonEnvironment,
resolution: &Resolution,
modifications: Modifications,
settings: InstallerSettingsRef<'_>,
state: &PlatformState,
logger: Box<dyn InstallLogger>,
Expand Down Expand Up @@ -1546,7 +1547,7 @@ pub(crate) async fn sync_environment(
pip::operations::install(
resolution,
site_packages,
Modifications::Exact,
modifications,
reinstall,
build_options,
link_mode,
Expand Down Expand Up @@ -1594,6 +1595,7 @@ impl EnvironmentUpdate {
pub(crate) async fn update_environment(
venv: PythonEnvironment,
spec: RequirementsSpecification,
modifications: Modifications,
settings: &ResolverInstallerSettings,
state: &SharedState,
resolve: Box<dyn ResolveLogger>,
Expand Down Expand Up @@ -1794,7 +1796,7 @@ pub(crate) async fn update_environment(
let changelog = pip::operations::install(
&resolution,
site_packages,
Modifications::Exact,
modifications,
reinstall,
build_options,
*link_mode,
Expand Down
3 changes: 3 additions & 0 deletions crates/uv/src/commands/tool/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use uv_warnings::warn_user;

use crate::commands::pip::loggers::{DefaultInstallLogger, DefaultResolveLogger};

use crate::commands::pip::operations::Modifications;
use crate::commands::project::{
resolve_environment, resolve_names, sync_environment, update_environment,
EnvironmentSpecification, PlatformState, ProjectError,
Expand Down Expand Up @@ -422,6 +423,7 @@ pub(crate) async fn install(
let environment = match update_environment(
environment,
spec,
Modifications::Exact,
&settings,
&state,
Box::new(DefaultResolveLogger),
Expand Down Expand Up @@ -551,6 +553,7 @@ pub(crate) async fn install(
match sync_environment(
environment,
&resolution.into(),
Modifications::Exact,
settings.as_ref().into(),
&state,
Box::new(DefaultInstallLogger),
Expand Down
3 changes: 3 additions & 0 deletions crates/uv/src/commands/tool/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use uv_tool::InstalledTools;
use crate::commands::pip::loggers::{
DefaultInstallLogger, SummaryResolveLogger, UpgradeInstallLogger,
};
use crate::commands::pip::operations::Modifications;
use crate::commands::project::{
resolve_environment, sync_environment, update_environment, EnvironmentUpdate, PlatformState,
};
Expand Down Expand Up @@ -314,6 +315,7 @@ async fn upgrade_tool(
let environment = sync_environment(
environment,
&resolution.into(),
Modifications::Exact,
settings.as_ref().into(),
&state,
Box::new(DefaultInstallLogger),
Expand All @@ -339,6 +341,7 @@ async fn upgrade_tool(
} = update_environment(
environment,
spec,
Modifications::Exact,
&settings,
&state,
Box::new(SummaryResolveLogger),
Expand Down

0 comments on commit d22a2df

Please sign in to comment.