diff --git a/crates/uv-cli/src/compat.rs b/crates/uv-cli/src/compat.rs index 31ec7f6d1..6288ab914 100644 --- a/crates/uv-cli/src/compat.rs +++ b/crates/uv-cli/src/compat.rs @@ -176,19 +176,26 @@ impl CompatArgs for PipCompileCompatArgs { #[derive(Args)] #[allow(clippy::struct_excessive_bools)] pub struct PipListCompatArgs { + #[clap(long, hide = true)] + disable_pip_version_check: bool, + #[clap(long, hide = true)] outdated: bool, } -impl CompatArgs for crate::compat::PipListCompatArgs { +impl CompatArgs for PipListCompatArgs { /// Validate the arguments passed for `pip list` compatibility. /// /// This method will warn when an argument is passed that has no effect but matches uv's /// behavior. If an argument is passed that does _not_ match uv's behavior (e.g., /// `--outdated`), this method will return an error. fn validate(&self) -> Result<()> { + if self.disable_pip_version_check { + warn_user!("pip's `--disable-pip-version-check` has no effect."); + } + if self.outdated { - return Err(anyhow!("pip list's `--outdated` is unsupported.")); + return Err(anyhow!("pip's `--outdated` is unsupported.")); } Ok(()) @@ -359,6 +366,9 @@ impl CompatArgs for VenvCompatArgs { #[derive(Args)] #[allow(clippy::struct_excessive_bools)] pub struct PipInstallCompatArgs { + #[clap(long, hide = true)] + disable_pip_version_check: bool, + #[clap(long, hide = false)] user: bool, } @@ -370,11 +380,41 @@ impl CompatArgs for PipInstallCompatArgs { /// behavior. If an argument is passed that does _not_ match uv's behavior, this method will /// return an error. fn validate(&self) -> Result<()> { + if self.disable_pip_version_check { + warn_user!("pip's `--disable-pip-version-check` has no effect."); + } + if self.user { return Err(anyhow!( - "pip install's `--user` is unsupported (use a virtual environment instead)." + "pip's `--user` is unsupported (use a virtual environment instead)." )); } + + Ok(()) + } +} + +/// Arguments for generic `pip` command compatibility. +/// +/// These represent a subset of the `pip` interface that exists on all commands. +#[derive(Args)] +#[allow(clippy::struct_excessive_bools)] +pub struct PipGlobalCompatArgs { + #[clap(long, hide = true)] + disable_pip_version_check: bool, +} + +impl CompatArgs for PipGlobalCompatArgs { + /// Validate the arguments passed for `pip` compatibility. + /// + /// This method will warn when an argument is passed that has no effect but matches uv's + /// behavior. If an argument is passed that does _not_ match uv's behavior, this method will + /// return an error. + fn validate(&self) -> Result<()> { + if self.disable_pip_version_check { + warn_user!("pip's `--disable-pip-version-check` has no effect."); + } + Ok(()) } } diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index a541942da..96f65a6f2 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -1205,6 +1205,9 @@ pub struct PipUninstallArgs { /// Uninstall packages from the specified `--prefix` directory. #[arg(long, conflicts_with = "target")] pub prefix: Option, + + #[command(flatten)] + pub compat_args: compat::PipGlobalCompatArgs, } #[derive(Args)] @@ -1255,6 +1258,9 @@ pub struct PipFreezeArgs { #[arg(long, overrides_with("system"), hide = true)] pub no_system: bool, + + #[command(flatten)] + pub compat_args: compat::PipGlobalCompatArgs, } #[derive(Args)] @@ -1407,6 +1413,9 @@ pub struct PipShowArgs { #[arg(long, overrides_with("system"), hide = true)] pub no_system: bool, + + #[command(flatten)] + pub compat_args: compat::PipGlobalCompatArgs, } #[derive(Args)] @@ -1468,6 +1477,9 @@ pub struct PipTreeArgs { #[arg(long, overrides_with("system"))] pub no_system: bool, + + #[command(flatten)] + pub compat_args: compat::PipGlobalCompatArgs, } #[derive(Args)] diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 29eae6687..6b42a51b5 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -921,6 +921,7 @@ impl PipUninstallSettings { no_break_system_packages, target, prefix, + compat_args: _, } = args; Self { @@ -960,6 +961,7 @@ impl PipFreezeSettings { python, system, no_system, + compat_args: _, } = args; Self { @@ -1040,6 +1042,7 @@ impl PipShowSettings { python, system, no_system, + compat_args: _, } = args; Self { @@ -1080,6 +1083,7 @@ impl PipTreeSettings { python, system, no_system, + compat_args: _, } = args; Self {