-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store unsupported tags in wheel filename #10665
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ Ok( | |
platform_tag: [ | ||
Any, | ||
], | ||
repr: "202206090410-py3-none-any", | ||
}, | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ Ok( | |
arch: X86_64, | ||
}, | ||
], | ||
repr: "cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64", | ||
}, | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,115 @@ | ||||||||||
use std::fmt::{Display, Formatter}; | ||||||||||
|
||||||||||
use crate::BuildTag; | ||||||||||
use uv_platform_tags::{AbiTag, LanguageTag, PlatformTag}; | ||||||||||
use uv_small_str::SmallString; | ||||||||||
|
||||||||||
/// A [`SmallVec`] type for storing tags. | ||||||||||
/// | ||||||||||
/// Wheels tend to include a single language, ABI, and platform tag, so we use a [`SmallVec`] with a | ||||||||||
/// capacity of 1 to optimize for this common case. | ||||||||||
pub(crate) type TagSet<T> = smallvec::SmallVec<[T; 3]>; | ||||||||||
|
||||||||||
/// The portion of the wheel filename following the name and version: the optional build tag, along | ||||||||||
/// with the Python tag(s), ABI tag(s), and platform tag(s). | ||||||||||
/// | ||||||||||
/// Most wheels consist of a single Python, ABI, and platform tag (and no build tag). We represent | ||||||||||
/// such wheels with [`WheelTagSmall`], a variant with a smaller memory footprint and (generally) | ||||||||||
/// zero allocations. The [`WheelTagLarge`] variant is used for wheels with multiple tags, a build | ||||||||||
/// tag, or an unsupported tag (i.e., a tag that can't be represented by [`LanguageTag`], | ||||||||||
/// [`AbiTag`], or [`PlatformTag`]). (Unsupported tags are filtered out, but retained in the display | ||||||||||
/// representation of [`WheelTagLarge`].) | ||||||||||
#[derive( | ||||||||||
Debug, | ||||||||||
Clone, | ||||||||||
Eq, | ||||||||||
PartialEq, | ||||||||||
Ord, | ||||||||||
PartialOrd, | ||||||||||
Hash, | ||||||||||
rkyv::Archive, | ||||||||||
rkyv::Deserialize, | ||||||||||
rkyv::Serialize, | ||||||||||
)] | ||||||||||
#[rkyv(derive(Debug))] | ||||||||||
pub(crate) enum WheelTag { | ||||||||||
Small { small: WheelTagSmall }, | ||||||||||
Large { large: Box<WheelTagLarge> }, | ||||||||||
} | ||||||||||
|
||||||||||
impl Display for WheelTag { | ||||||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||||||||||
match self { | ||||||||||
Self::Small { small } => write!(f, "{small}"), | ||||||||||
Self::Large { large } => write!(f, "{large}"), | ||||||||||
} | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
#[derive( | ||||||||||
Debug, | ||||||||||
Clone, | ||||||||||
Eq, | ||||||||||
PartialEq, | ||||||||||
Ord, | ||||||||||
PartialOrd, | ||||||||||
Hash, | ||||||||||
rkyv::Archive, | ||||||||||
rkyv::Deserialize, | ||||||||||
rkyv::Serialize, | ||||||||||
)] | ||||||||||
#[rkyv(derive(Debug))] | ||||||||||
#[allow(clippy::struct_field_names)] | ||||||||||
pub(crate) struct WheelTagSmall { | ||||||||||
/// The Python tag, e.g., `py3` in `1.2.3-py3-none-any`. | ||||||||||
pub(crate) python_tag: LanguageTag, | ||||||||||
/// The ABI tag, e.g., `none` in `1.2.3-py3-none-any`. | ||||||||||
pub(crate) abi_tag: AbiTag, | ||||||||||
/// The platform tag, e.g., `none` in `1.2.3-py3-none-any`. | ||||||||||
pub(crate) platform_tag: PlatformTag, | ||||||||||
} | ||||||||||
|
||||||||||
impl Display for WheelTagSmall { | ||||||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||||||||||
write!( | ||||||||||
f, | ||||||||||
"{}-{}-{}", | ||||||||||
self.python_tag, self.abi_tag, self.platform_tag | ||||||||||
) | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
#[derive( | ||||||||||
Debug, | ||||||||||
Clone, | ||||||||||
Eq, | ||||||||||
PartialEq, | ||||||||||
Ord, | ||||||||||
PartialOrd, | ||||||||||
Hash, | ||||||||||
rkyv::Archive, | ||||||||||
rkyv::Deserialize, | ||||||||||
rkyv::Serialize, | ||||||||||
)] | ||||||||||
#[rkyv(derive(Debug))] | ||||||||||
#[allow(clippy::struct_field_names)] | ||||||||||
pub(crate) struct WheelTagLarge { | ||||||||||
/// The optional build tag, e.g., `73` in `1.2.3-73-py3-none-any`. | ||||||||||
pub(crate) build_tag: Option<BuildTag>, | ||||||||||
/// The Python tag(s), e.g., `py3` in `1.2.3-73-py3-none-any`. | ||||||||||
pub(crate) python_tag: TagSet<LanguageTag>, | ||||||||||
/// The ABI tag(s), e.g., `none` in `1.2.3-73-py3-none-any`. | ||||||||||
pub(crate) abi_tag: TagSet<AbiTag>, | ||||||||||
/// The platform tag(s), e.g., `none` in `1.2.3-73-py3-none-any`. | ||||||||||
pub(crate) platform_tag: TagSet<PlatformTag>, | ||||||||||
/// The string representation of the tag. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
/// | ||||||||||
/// Preserves any unsupported tags that were filtered out when parsing the wheel filename. | ||||||||||
pub(crate) repr: SmallString, | ||||||||||
} | ||||||||||
|
||||||||||
impl Display for WheelTagLarge { | ||||||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||||||||||
write!(f, "{}", self.repr) | ||||||||||
} | ||||||||||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these comments got mixed up, is
1.2.3-73-py3-none-any-none
a supported tag?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah thanks, yeah