mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Respect resolver settings in uv remove
(#4930)
## Summary Closes https://github.com/astral-sh/uv/issues/4925
This commit is contained in:
parent
5f20bdb2ee
commit
92290d8dcb
10 changed files with 32 additions and 15 deletions
|
@ -1946,6 +1946,15 @@ pub struct RemoveArgs {
|
||||||
#[arg(long, conflicts_with("dev"))]
|
#[arg(long, conflicts_with("dev"))]
|
||||||
pub optional: Option<ExtraName>,
|
pub optional: Option<ExtraName>,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
pub installer: ResolverInstallerArgs,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
pub build: BuildArgs,
|
||||||
|
|
||||||
|
#[command(flatten)]
|
||||||
|
pub refresh: RefreshArgs,
|
||||||
|
|
||||||
/// Remove the dependency from a specific package in the workspace.
|
/// Remove the dependency from a specific package in the workspace.
|
||||||
#[arg(long, conflicts_with = "isolated")]
|
#[arg(long, conflicts_with = "isolated")]
|
||||||
pub package: Option<PackageName>,
|
pub package: Option<PackageName>,
|
||||||
|
|
|
@ -43,7 +43,7 @@ use crate::commands::ExitStatus;
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
|
|
||||||
/// Resolve a set of requirements into a set of pinned versions.
|
/// Resolve a set of requirements into a set of pinned versions.
|
||||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(crate) async fn pip_compile(
|
pub(crate) async fn pip_compile(
|
||||||
requirements: &[RequirementsSource],
|
requirements: &[RequirementsSource],
|
||||||
constraints: &[RequirementsSource],
|
constraints: &[RequirementsSource],
|
||||||
|
|
|
@ -35,7 +35,7 @@ use crate::commands::{elapsed, ExitStatus, SharedState};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
|
|
||||||
/// Install packages into the current environment.
|
/// Install packages into the current environment.
|
||||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(crate) async fn pip_install(
|
pub(crate) async fn pip_install(
|
||||||
requirements: &[RequirementsSource],
|
requirements: &[RequirementsSource],
|
||||||
constraints: &[RequirementsSource],
|
constraints: &[RequirementsSource],
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::commands::ExitStatus;
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
|
|
||||||
/// Enumerate the installed packages in the current environment.
|
/// Enumerate the installed packages in the current environment.
|
||||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(crate) fn pip_list(
|
pub(crate) fn pip_list(
|
||||||
editable: bool,
|
editable: bool,
|
||||||
exclude_editable: bool,
|
exclude_editable: bool,
|
||||||
|
|
|
@ -34,7 +34,7 @@ use crate::commands::{ExitStatus, SharedState};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
|
|
||||||
/// Install a set of locked requirements into the current Python environment.
|
/// Install a set of locked requirements into the current Python environment.
|
||||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(crate) async fn pip_sync(
|
pub(crate) async fn pip_sync(
|
||||||
requirements: &[RequirementsSource],
|
requirements: &[RequirementsSource],
|
||||||
constraints: &[RequirementsSource],
|
constraints: &[RequirementsSource],
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::printer::Printer;
|
||||||
use crate::settings::ResolverInstallerSettings;
|
use crate::settings::ResolverInstallerSettings;
|
||||||
|
|
||||||
/// Add one or more packages to the project requirements.
|
/// Add one or more packages to the project requirements.
|
||||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(crate) async fn add(
|
pub(crate) async fn add(
|
||||||
requirements: Vec<RequirementsSource>,
|
requirements: Vec<RequirementsSource>,
|
||||||
editable: Option<bool>,
|
editable: Option<bool>,
|
||||||
|
|
|
@ -13,7 +13,7 @@ use uv_warnings::{warn_user, warn_user_once};
|
||||||
use crate::commands::pip::operations::Modifications;
|
use crate::commands::pip::operations::Modifications;
|
||||||
use crate::commands::{project, ExitStatus, SharedState};
|
use crate::commands::{project, ExitStatus, SharedState};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::settings::{InstallerSettings, ResolverSettings};
|
use crate::settings::ResolverInstallerSettings;
|
||||||
|
|
||||||
/// Remove one or more packages from the project requirements.
|
/// Remove one or more packages from the project requirements.
|
||||||
pub(crate) async fn remove(
|
pub(crate) async fn remove(
|
||||||
|
@ -21,6 +21,7 @@ pub(crate) async fn remove(
|
||||||
dependency_type: DependencyType,
|
dependency_type: DependencyType,
|
||||||
package: Option<PackageName>,
|
package: Option<PackageName>,
|
||||||
python: Option<String>,
|
python: Option<String>,
|
||||||
|
settings: ResolverInstallerSettings,
|
||||||
python_preference: PythonPreference,
|
python_preference: PythonPreference,
|
||||||
python_fetch: PythonFetch,
|
python_fetch: PythonFetch,
|
||||||
preview: PreviewMode,
|
preview: PreviewMode,
|
||||||
|
@ -94,9 +95,6 @@ pub(crate) async fn remove(
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Use the default settings.
|
|
||||||
let settings = ResolverSettings::default();
|
|
||||||
|
|
||||||
// Initialize any shared state.
|
// Initialize any shared state.
|
||||||
let state = SharedState::default();
|
let state = SharedState::default();
|
||||||
|
|
||||||
|
@ -104,7 +102,7 @@ pub(crate) async fn remove(
|
||||||
let lock = project::lock::do_lock(
|
let lock = project::lock::do_lock(
|
||||||
project.workspace(),
|
project.workspace(),
|
||||||
venv.interpreter(),
|
venv.interpreter(),
|
||||||
settings.as_ref(),
|
settings.as_ref().into(),
|
||||||
&state,
|
&state,
|
||||||
preview,
|
preview,
|
||||||
connectivity,
|
connectivity,
|
||||||
|
@ -117,7 +115,6 @@ pub(crate) async fn remove(
|
||||||
|
|
||||||
// Perform a full sync, because we don't know what exactly is affected by the removal.
|
// Perform a full sync, because we don't know what exactly is affected by the removal.
|
||||||
// TODO(ibraheem): Should we accept CLI overrides for this? Should we even sync here?
|
// TODO(ibraheem): Should we accept CLI overrides for this? Should we even sync here?
|
||||||
let settings = InstallerSettings::default();
|
|
||||||
let extras = ExtrasSpecification::All;
|
let extras = ExtrasSpecification::All;
|
||||||
let dev = true;
|
let dev = true;
|
||||||
|
|
||||||
|
@ -128,7 +125,7 @@ pub(crate) async fn remove(
|
||||||
extras,
|
extras,
|
||||||
dev,
|
dev,
|
||||||
Modifications::Exact,
|
Modifications::Exact,
|
||||||
settings.as_ref(),
|
settings.as_ref().into(),
|
||||||
&state,
|
&state,
|
||||||
preview,
|
preview,
|
||||||
connectivity,
|
connectivity,
|
||||||
|
|
|
@ -105,7 +105,7 @@ enum VenvError {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a virtual environment.
|
/// Create a virtual environment.
|
||||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
async fn venv_impl(
|
async fn venv_impl(
|
||||||
path: &Path,
|
path: &Path,
|
||||||
python_request: Option<&str>,
|
python_request: Option<&str>,
|
||||||
|
|
|
@ -959,13 +959,14 @@ async fn run_project(
|
||||||
show_settings!(args);
|
show_settings!(args);
|
||||||
|
|
||||||
// Initialize the cache.
|
// Initialize the cache.
|
||||||
let cache = cache.init()?;
|
let cache = cache.init()?.with_refresh(args.refresh);
|
||||||
|
|
||||||
commands::remove(
|
commands::remove(
|
||||||
args.requirements,
|
args.requirements,
|
||||||
args.dependency_type,
|
args.dependency_type,
|
||||||
args.package,
|
args.package,
|
||||||
args.python,
|
args.python,
|
||||||
|
args.settings,
|
||||||
globals.python_preference,
|
globals.python_preference,
|
||||||
globals.python_fetch,
|
globals.python_fetch,
|
||||||
globals.preview,
|
globals.preview,
|
||||||
|
|
|
@ -565,16 +565,21 @@ pub(crate) struct RemoveSettings {
|
||||||
pub(crate) dependency_type: DependencyType,
|
pub(crate) dependency_type: DependencyType,
|
||||||
pub(crate) package: Option<PackageName>,
|
pub(crate) package: Option<PackageName>,
|
||||||
pub(crate) python: Option<String>,
|
pub(crate) python: Option<String>,
|
||||||
|
pub(crate) refresh: Refresh,
|
||||||
|
pub(crate) settings: ResolverInstallerSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RemoveSettings {
|
impl RemoveSettings {
|
||||||
/// Resolve the [`RemoveSettings`] from the CLI and filesystem configuration.
|
/// Resolve the [`RemoveSettings`] from the CLI and filesystem configuration.
|
||||||
#[allow(clippy::needless_pass_by_value)]
|
#[allow(clippy::needless_pass_by_value)]
|
||||||
pub(crate) fn resolve(args: RemoveArgs, _filesystem: Option<FilesystemOptions>) -> Self {
|
pub(crate) fn resolve(args: RemoveArgs, filesystem: Option<FilesystemOptions>) -> Self {
|
||||||
let RemoveArgs {
|
let RemoveArgs {
|
||||||
dev,
|
dev,
|
||||||
optional,
|
optional,
|
||||||
requirements,
|
requirements,
|
||||||
|
installer,
|
||||||
|
build,
|
||||||
|
refresh,
|
||||||
package,
|
package,
|
||||||
python,
|
python,
|
||||||
} = args;
|
} = args;
|
||||||
|
@ -592,6 +597,11 @@ impl RemoveSettings {
|
||||||
dependency_type,
|
dependency_type,
|
||||||
package,
|
package,
|
||||||
python,
|
python,
|
||||||
|
refresh: Refresh::from(refresh),
|
||||||
|
settings: ResolverInstallerSettings::combine(
|
||||||
|
resolver_installer_options(installer, build),
|
||||||
|
filesystem,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue