mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25: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"))]
|
||||
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.
|
||||
#[arg(long, conflicts_with = "isolated")]
|
||||
pub package: Option<PackageName>,
|
||||
|
|
|
@ -43,7 +43,7 @@ use crate::commands::ExitStatus;
|
|||
use crate::printer::Printer;
|
||||
|
||||
/// 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(
|
||||
requirements: &[RequirementsSource],
|
||||
constraints: &[RequirementsSource],
|
||||
|
|
|
@ -35,7 +35,7 @@ use crate::commands::{elapsed, ExitStatus, SharedState};
|
|||
use crate::printer::Printer;
|
||||
|
||||
/// 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(
|
||||
requirements: &[RequirementsSource],
|
||||
constraints: &[RequirementsSource],
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::commands::ExitStatus;
|
|||
use crate::printer::Printer;
|
||||
|
||||
/// 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(
|
||||
editable: bool,
|
||||
exclude_editable: bool,
|
||||
|
|
|
@ -34,7 +34,7 @@ use crate::commands::{ExitStatus, SharedState};
|
|||
use crate::printer::Printer;
|
||||
|
||||
/// 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(
|
||||
requirements: &[RequirementsSource],
|
||||
constraints: &[RequirementsSource],
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::printer::Printer;
|
|||
use crate::settings::ResolverInstallerSettings;
|
||||
|
||||
/// 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(
|
||||
requirements: Vec<RequirementsSource>,
|
||||
editable: Option<bool>,
|
||||
|
|
|
@ -13,7 +13,7 @@ use uv_warnings::{warn_user, warn_user_once};
|
|||
use crate::commands::pip::operations::Modifications;
|
||||
use crate::commands::{project, ExitStatus, SharedState};
|
||||
use crate::printer::Printer;
|
||||
use crate::settings::{InstallerSettings, ResolverSettings};
|
||||
use crate::settings::ResolverInstallerSettings;
|
||||
|
||||
/// Remove one or more packages from the project requirements.
|
||||
pub(crate) async fn remove(
|
||||
|
@ -21,6 +21,7 @@ pub(crate) async fn remove(
|
|||
dependency_type: DependencyType,
|
||||
package: Option<PackageName>,
|
||||
python: Option<String>,
|
||||
settings: ResolverInstallerSettings,
|
||||
python_preference: PythonPreference,
|
||||
python_fetch: PythonFetch,
|
||||
preview: PreviewMode,
|
||||
|
@ -94,9 +95,6 @@ pub(crate) async fn remove(
|
|||
)
|
||||
.await?;
|
||||
|
||||
// Use the default settings.
|
||||
let settings = ResolverSettings::default();
|
||||
|
||||
// Initialize any shared state.
|
||||
let state = SharedState::default();
|
||||
|
||||
|
@ -104,7 +102,7 @@ pub(crate) async fn remove(
|
|||
let lock = project::lock::do_lock(
|
||||
project.workspace(),
|
||||
venv.interpreter(),
|
||||
settings.as_ref(),
|
||||
settings.as_ref().into(),
|
||||
&state,
|
||||
preview,
|
||||
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.
|
||||
// TODO(ibraheem): Should we accept CLI overrides for this? Should we even sync here?
|
||||
let settings = InstallerSettings::default();
|
||||
let extras = ExtrasSpecification::All;
|
||||
let dev = true;
|
||||
|
||||
|
@ -128,7 +125,7 @@ pub(crate) async fn remove(
|
|||
extras,
|
||||
dev,
|
||||
Modifications::Exact,
|
||||
settings.as_ref(),
|
||||
settings.as_ref().into(),
|
||||
&state,
|
||||
preview,
|
||||
connectivity,
|
||||
|
|
|
@ -105,7 +105,7 @@ enum VenvError {
|
|||
}
|
||||
|
||||
/// Create a virtual environment.
|
||||
#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
async fn venv_impl(
|
||||
path: &Path,
|
||||
python_request: Option<&str>,
|
||||
|
|
|
@ -959,13 +959,14 @@ async fn run_project(
|
|||
show_settings!(args);
|
||||
|
||||
// Initialize the cache.
|
||||
let cache = cache.init()?;
|
||||
let cache = cache.init()?.with_refresh(args.refresh);
|
||||
|
||||
commands::remove(
|
||||
args.requirements,
|
||||
args.dependency_type,
|
||||
args.package,
|
||||
args.python,
|
||||
args.settings,
|
||||
globals.python_preference,
|
||||
globals.python_fetch,
|
||||
globals.preview,
|
||||
|
|
|
@ -565,16 +565,21 @@ pub(crate) struct RemoveSettings {
|
|||
pub(crate) dependency_type: DependencyType,
|
||||
pub(crate) package: Option<PackageName>,
|
||||
pub(crate) python: Option<String>,
|
||||
pub(crate) refresh: Refresh,
|
||||
pub(crate) settings: ResolverInstallerSettings,
|
||||
}
|
||||
|
||||
impl RemoveSettings {
|
||||
/// Resolve the [`RemoveSettings`] from the CLI and filesystem configuration.
|
||||
#[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 {
|
||||
dev,
|
||||
optional,
|
||||
requirements,
|
||||
installer,
|
||||
build,
|
||||
refresh,
|
||||
package,
|
||||
python,
|
||||
} = args;
|
||||
|
@ -592,6 +597,11 @@ impl RemoveSettings {
|
|||
dependency_type,
|
||||
package,
|
||||
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