Add --python-platform to uv pip check (#15486)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | aarch64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / mkdocs (push) Waiting to run
CI / build binary | linux libc (push) Blocked by required conditions
CI / build binary | linux aarch64 (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / build binary | freebsd (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / build binary | msrv (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / smoke test | linux aarch64 (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | pyodide on ubuntu (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | pyenv on wsl x86-64 (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | aarch64 windows implicit (push) Blocked by required conditions
CI / integration test | aarch64 windows explicit (push) Blocked by required conditions
CI / integration test | registries (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | aarch64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks | walltime aarch64 linux (push) Blocked by required conditions
CI / benchmarks | instrumented (push) Blocked by required conditions
zizmor / Run zizmor (push) Waiting to run
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | graalpy on ubuntu (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions

## Summary

I want this to facilitate some testing for
https://github.com/astral-sh/uv/issues/15035.
This commit is contained in:
Charlie Marsh 2025-08-24 14:14:42 -04:00 committed by GitHub
parent 99f1f4fee4
commit d19d0e26aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 118 additions and 4 deletions

View file

@ -2373,6 +2373,27 @@ pub struct PipCheckArgs {
#[arg(long, overrides_with("system"), hide = true)]
pub no_system: bool,
/// The Python version against which packages should be checked.
///
/// By default, the installed packages are checked against the version of the current
/// interpreter.
#[arg(long)]
pub python_version: Option<PythonVersion>,
/// The platform for which packages should be checked.
///
/// By default, the installed packages are checked against the platform of the current
/// interpreter.
///
/// Represented as a "target triple", a string that describes the target platform in terms of
/// its CPU, vendor, and operating system name, like `x86_64-unknown-linux-gnu` or
/// `aarch64-apple-darwin`.
///
/// When targeting macOS (Darwin), the default minimum version is `12.0`. Use
/// `MACOSX_DEPLOYMENT_TARGET` to specify a different minimum version, e.g., `13.0`.
#[arg(long)]
pub python_platform: Option<TargetTriple>,
}
#[derive(Args)]

View file

@ -5,13 +5,16 @@ use anyhow::Result;
use owo_colors::OwoColorize;
use uv_cache::Cache;
use uv_configuration::TargetTriple;
use uv_distribution_types::{Diagnostic, InstalledDist};
use uv_installer::{SitePackages, SitePackagesDiagnostic};
use uv_preview::Preview;
use uv_python::PythonPreference;
use uv_python::{EnvironmentPreference, PythonEnvironment, PythonRequest};
use uv_python::{
EnvironmentPreference, PythonEnvironment, PythonPreference, PythonRequest, PythonVersion,
};
use crate::commands::pip::operations::report_target_environment;
use crate::commands::pip::resolution_markers;
use crate::commands::{ExitStatus, elapsed};
use crate::printer::Printer;
@ -19,6 +22,8 @@ use crate::printer::Printer;
pub(crate) fn pip_check(
python: Option<&str>,
system: bool,
python_version: Option<&PythonVersion>,
python_platform: Option<&TargetTriple>,
cache: &Cache,
printer: Printer,
preview: Preview,
@ -53,7 +58,7 @@ pub(crate) fn pip_check(
)?;
// Determine the markers to use for resolution.
let markers = environment.interpreter().resolver_marker_environment();
let markers = resolution_markers(python_version, python_platform, environment.interpreter());
// Run the diagnostics.
let diagnostics: Vec<SitePackagesDiagnostic> =

View file

@ -916,6 +916,8 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
commands::pip_check(
args.settings.python.as_deref(),
args.settings.system,
args.python_version.as_ref(),
args.python_platform.as_ref(),
&cache,
printer,
globals.preview,

View file

@ -2589,6 +2589,8 @@ impl PipTreeSettings {
#[derive(Debug, Clone)]
pub(crate) struct PipCheckSettings {
pub(crate) settings: PipSettings,
pub(crate) python_version: Option<PythonVersion>,
pub(crate) python_platform: Option<TargetTriple>,
}
impl PipCheckSettings {
@ -2598,6 +2600,8 @@ impl PipCheckSettings {
python,
system,
no_system,
python_version,
python_platform,
} = args;
Self {
@ -2609,6 +2613,8 @@ impl PipCheckSettings {
},
filesystem,
),
python_version,
python_platform,
}
}
}

View file

@ -187,3 +187,36 @@ fn check_multiple_incompatible_packages() -> Result<()> {
Ok(())
}
#[test]
fn check_python_version() {
let context = TestContext::new("3.12");
uv_snapshot!(context
.pip_install()
.arg("urllib3")
.arg("--strict"), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ urllib3==2.2.1
"
);
uv_snapshot!(context.filters(), context.pip_check().arg("--python-version").arg("3.7"), @r"
success: false
exit_code: 1
----- stdout -----
----- stderr -----
Checked 1 package in [TIME]
Found 1 incompatibility
The package `urllib3` requires Python >=3.8, but `3.12.[X]` is installed
"
);
}