Skip to content

Commit

Permalink
Remove this
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jan 14, 2025
1 parent 120d1cc commit 9287146
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 32 deletions.
8 changes: 4 additions & 4 deletions crates/uv-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ name = "distribution-filename"
path = "benches/distribution_filename.rs"
harness = false

[[bench]]
name = "uv"
path = "benches/uv.rs"
harness = false
# [[bench]]
# name = "uv"
# path = "benches/uv.rs"
# harness = false

[dependencies]
uv-cache = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/uv-bench/benches/distribution_filename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ fn benchmark_wheelname_tag_compatibility(c: &mut Criterion<WallTime>) {

criterion_group!(
uv_distribution_filename,
benchmark_build_platform_tags,
// benchmark_build_platform_tags,
benchmark_wheelname_parsing,
benchmark_wheelname_parsing_failure,
benchmark_wheelname_tag_compatibility,
// benchmark_wheelname_tag_compatibility,
);
criterion_main!(uv_distribution_filename);
107 changes: 81 additions & 26 deletions crates/uv-distribution-filename/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ impl WheelTag {
}
}



pub fn python_tags(&self) -> &[LanguageTag] {
match self {
Self::Small { small } => std::slice::from_ref(&small.python_tag),
Expand Down Expand Up @@ -150,9 +152,9 @@ impl Display for WheelTagSmall {
#[rkyv(derive(Debug))]
pub struct WheelTagLarge {
build_tag: Option<BuildTag>,
python_tag: TagSet<LanguageTag>,
abi_tag: TagSet<AbiTag>,
platform_tag: TagSet<PlatformTag>,
python_tag: Vec<LanguageTag>,
abi_tag: Vec<AbiTag>,
platform_tag: Vec<PlatformTag>,
}

impl Display for WheelTagLarge {
Expand Down Expand Up @@ -311,39 +313,92 @@ impl WheelFilename {
})
.transpose()?;

let tags = if build_tag.is_some() || python_tag.contains('.') || abi_tag.contains('.') || platform_tag.contains('.') {
WheelTag::Large {
let mut python_tags = python_tag.split('.').map(LanguageTag::from_str);
let mut abi_tags = abi_tag.split('.').map(AbiTag::from_str);
let mut platform_tags = platform_tag.split('.').map(PlatformTag::from_str);

// Identify the first tag of each type.
let python_tag = python_tags
.next()
.ok_or_else(|| WheelFilenameError::MissingLanguageTag(filename.to_string()))?
.map_err(|err| WheelFilenameError::InvalidLanguageTag(filename.to_string(), err))?;
let abi_tag = abi_tags
.next()
.ok_or_else(|| WheelFilenameError::MissingAbiTag(filename.to_string()))?
.map_err(|err| WheelFilenameError::InvalidAbiTag(filename.to_string(), err))?;
let platform_tag = platform_tags
.next()
.ok_or_else(|| WheelFilenameError::MissingPlatformTag(filename.to_string()))?
.map_err(|err| WheelFilenameError::InvalidPlatformTag(filename.to_string(), err))?;

let tags = match (
python_tags.next(),
abi_tags.next(),
platform_tags.next(),
) {
(None, None, None) if build_tag.is_none() => WheelTag::Small {
small: WheelTagSmall {
python_tag,
abi_tag,
platform_tag
},
},
(next_python_tag, next_abi_tag, next_platform_tag) => WheelTag::Large {
large: Box::new(WheelTagLarge {
build_tag,
python_tag: python_tag
.split('.')
.map(LanguageTag::from_str)
python_tag: std::iter::once(python_tag)
.chain(next_python_tag.transpose().map_err(|err| WheelFilenameError::InvalidLanguageTag(filename.to_string(), err))?)
.chain(python_tags)
.collect::<Result<_, _>>()
.map_err(|err| WheelFilenameError::InvalidLanguageTag(filename.to_string(), err))?,
abi_tag: abi_tag
.split('.')
.map(AbiTag::from_str)
abi_tag: std::iter::once(abi_tag)
.chain(next_abi_tag.transpose()?)
.chain(abi_tags)
.collect::<Result<_, _>>()
.map_err(|err| WheelFilenameError::InvalidAbiTag(filename.to_string(), err))?,
platform_tag: platform_tag
.split('.')
.map(PlatformTag::from_str)
platform_tag: std::iter::once(platform_tag)
.chain(next_platform_tag.transpose()?)
.chain(platform_tags)
.collect::<Result<_, _>>()
.map_err(|err| WheelFilenameError::InvalidPlatformTag(filename.to_string(), err))?,
}),
}
} else {
WheelTag::Small {
small: WheelTagSmall {
python_tag: LanguageTag::from_str(python_tag)
.map_err(|err| WheelFilenameError::InvalidLanguageTag(filename.to_string(), err))?,
abi_tag: AbiTag::from_str(abi_tag)
.map_err(|err| WheelFilenameError::InvalidAbiTag(filename.to_string(), err))?,
platform_tag: PlatformTag::from_str(platform_tag)
.map_err(|err| WheelFilenameError::InvalidPlatformTag(filename.to_string(), err))?,
},
}
},
};
//
//
// let tags = if build_tag.is_some() || python_tag.contains('.') || abi_tag.contains('.') || platform_tag.contains('.') {
// WheelTag::Large {
// large: Box::new(WheelTagLarge {
// build_tag,
// python_tag: python_tag
// .split('.')
// .map(LanguageTag::from_str)
// .collect::<Result<_, _>>()
// .map_err(|err| WheelFilenameError::InvalidLanguageTag(filename.to_string(), err))?,
// abi_tag: abi_tag
// .split('.')
// .map(AbiTag::from_str)
// .collect::<Result<_, _>>()
// .map_err(|err| WheelFilenameError::InvalidAbiTag(filename.to_string(), err))?,
// platform_tag: platform_tag
// .split('.')
// .map(PlatformTag::from_str)
// .collect::<Result<_, _>>()
// .map_err(|err| WheelFilenameError::InvalidPlatformTag(filename.to_string(), err))?,
// }),
// }
// } else {
// WheelTag::Small {
// small: WheelTagSmall {
// python_tag: LanguageTag::from_str(python_tag)
// .map_err(|err| WheelFilenameError::InvalidLanguageTag(filename.to_string(), err))?,
// abi_tag: AbiTag::from_str(abi_tag)
// .map_err(|err| WheelFilenameError::InvalidAbiTag(filename.to_string(), err))?,
// platform_tag: PlatformTag::from_str(platform_tag)
// .map_err(|err| WheelFilenameError::InvalidPlatformTag(filename.to_string(), err))?,
// },
// }
// };

Ok(Self {
name,
Expand Down

0 comments on commit 9287146

Please sign in to comment.