Use short-form for platform tag checks (#10737)

This commit is contained in:
Charlie Marsh 2025-01-18 13:22:09 -05:00 committed by GitHub
parent 1bfa7230fc
commit 3fe4e7168b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,7 +32,7 @@ use uv_git::{GitReference, GitSha, RepositoryReference, ResolvedRepositoryRefere
use uv_normalize::{ExtraName, GroupName, PackageName};
use uv_pep440::Version;
use uv_pep508::{split_scheme, MarkerEnvironment, MarkerTree, VerbatimUrl, VerbatimUrlError};
use uv_platform_tags::{TagCompatibility, TagPriority, Tags};
use uv_platform_tags::{PlatformTag, TagCompatibility, TagPriority, Tags};
use uv_pypi_types::{
redact_credentials, ConflictPackage, Conflicts, HashDigest, ParsedArchiveUrl, ParsedGitUrl,
Requirement, RequirementSource,
@ -292,19 +292,13 @@ impl Lock {
// a single disjointness check with the intersection is sufficient, so we have one
// constant per platform.
let platform_tags = wheel.filename.platform_tags();
if platform_tags
.iter()
.all(uv_platform_tags::PlatformTag::is_linux)
{
if platform_tags.iter().all(PlatformTag::is_linux) {
if graph.graph[node_index].marker().is_disjoint(*LINUX_MARKERS) {
return false;
}
}
if platform_tags
.iter()
.all(uv_platform_tags::PlatformTag::is_windows)
{
if platform_tags.iter().all(PlatformTag::is_windows) {
// TODO(charlie): This omits `win_ia64`, which is accepted by Warehouse.
if graph.graph[node_index]
.marker()
@ -314,28 +308,19 @@ impl Lock {
}
}
if platform_tags
.iter()
.all(uv_platform_tags::PlatformTag::is_macos)
{
if platform_tags.iter().all(PlatformTag::is_macos) {
if graph.graph[node_index].marker().is_disjoint(*MAC_MARKERS) {
return false;
}
}
if platform_tags
.iter()
.all(uv_platform_tags::PlatformTag::is_arm)
{
if platform_tags.iter().all(PlatformTag::is_arm) {
if graph.graph[node_index].marker().is_disjoint(*ARM_MARKERS) {
return false;
}
}
if platform_tags
.iter()
.all(uv_platform_tags::PlatformTag::is_x86_64)
{
if platform_tags.iter().all(PlatformTag::is_x86_64) {
if graph.graph[node_index]
.marker()
.is_disjoint(*X86_64_MARKERS)
@ -344,10 +329,7 @@ impl Lock {
}
}
if platform_tags
.iter()
.all(uv_platform_tags::PlatformTag::is_x86)
{
if platform_tags.iter().all(PlatformTag::is_x86) {
if graph.graph[node_index].marker().is_disjoint(*X86_MARKERS) {
return false;
}