pub struct RequiresPython { /* private fields */ }Expand description
The Requires-Python requirement specifier.
See: https://packaging.python.org/en/latest/guides/dropping-older-python-versions/
Implementations§
Source§impl RequiresPython
impl RequiresPython
Sourcepub fn greater_than_equal_version(version: &Version) -> Self
pub fn greater_than_equal_version(version: &Version) -> Self
Returns a RequiresPython to express >= equality with the given version.
Sourcepub fn from_specifiers(specifiers: &VersionSpecifiers) -> Self
pub fn from_specifiers(specifiers: &VersionSpecifiers) -> Self
Returns a RequiresPython from a version specifier.
Sourcepub fn intersection<'a>(
specifiers: impl Iterator<Item = &'a VersionSpecifiers>,
) -> Option<Self>
pub fn intersection<'a>( specifiers: impl Iterator<Item = &'a VersionSpecifiers>, ) -> Option<Self>
Returns a RequiresPython to express the intersection of the given version specifiers.
For example, given >=3.8 and >=3.9, this would return >=3.9.
Sourcepub fn split(&self, bound: Bound<Version>) -> Option<(Self, Self)>
pub fn split(&self, bound: Bound<Version>) -> Option<(Self, Self)>
Split the RequiresPython at the given version.
For example, if the current requirement is >=3.10, and the split point is 3.11, then
the result will be >=3.10 and <3.11 and >=3.11.
Sourcepub fn narrow(&self, range: &RequiresPythonRange) -> Option<Self>
pub fn narrow(&self, range: &RequiresPythonRange) -> Option<Self>
Narrow the RequiresPython by computing the intersection with the given range.
Returns None if the given range is not narrower than the current range.
Sourcepub fn to_marker_tree(&self) -> MarkerTree
pub fn to_marker_tree(&self) -> MarkerTree
Returns this Requires-Python specifier as an equivalent
MarkerTree utilizing the python_full_version marker field.
This is useful for comparing a Requires-Python specifier with
arbitrary marker expressions. For example, one can ask whether the
returned marker expression is disjoint with another marker expression.
If it is, then one can conclude that the Requires-Python specifier
excludes the dependency with that other marker expression.
If this Requires-Python specifier has no constraints, then this
returns a marker tree that evaluates to true for all possible marker
environments.
Sourcepub fn contains(&self, version: &Version) -> bool
pub fn contains(&self, version: &Version) -> bool
Returns true if the Requires-Python is compatible with the given version.
N.B. This operation should primarily be used when evaluating compatibility of Python
versions against the user’s own project. For example, if the user defines a
requires-python in a pyproject.toml, this operation could be used to determine whether
a given Python interpreter is compatible with the user’s project.
Sourcepub fn is_contained_by(&self, target: &VersionSpecifiers) -> bool
pub fn is_contained_by(&self, target: &VersionSpecifiers) -> bool
Returns true if the Requires-Python is contained by the given version specifiers.
In this context, we treat Requires-Python as a lower bound. For example, if the
requirement expresses >=3.8, <4, we treat it as >=3.8. Requires-Python itself was
intended to enable packages to drop support for older versions of Python without breaking
installations on those versions, and packages cannot know whether they are compatible with
future, unreleased versions of Python.
The specifiers are considered to “contain” the Requires-Python if the specifiers are
compatible with all versions in the Requires-Python range (i.e., have a lower lower
bound).
For example, if the Requires-Python is >=3.8, then >=3.7 would be considered
compatible, since all versions in the Requires-Python range are also covered by the
provided range. However, >=3.9 would not be considered compatible, as the
Requires-Python includes Python 3.8, but >=3.9 does not.
N.B. This operation should primarily be used when evaluating the compatibility of a
project’s Requires-Python specifier against a dependency’s Requires-Python specifier.
Sourcepub fn specifiers(&self) -> &VersionSpecifiers
pub fn specifiers(&self) -> &VersionSpecifiers
Returns the VersionSpecifiers for the Requires-Python specifier.
Sourcepub fn is_unbounded(&self) -> bool
pub fn is_unbounded(&self) -> bool
Returns true if the Requires-Python specifier is unbounded.
Sourcepub fn is_exact_without_patch(&self) -> bool
pub fn is_exact_without_patch(&self) -> bool
Returns true if the Requires-Python specifier is set to an exact version
without specifying a patch version. (e.g. ==3.10)
Sourcepub fn range(&self) -> &RequiresPythonRange
pub fn range(&self) -> &RequiresPythonRange
Returns the [Range] bounding the Requires-Python specifier.
Sourcepub fn abi_tag(&self) -> Option<AbiTag>
pub fn abi_tag(&self) -> Option<AbiTag>
Returns a wheel tag that’s compatible with the Requires-Python specifier.
Sourcepub fn simplify_markers(&self, marker: MarkerTree) -> MarkerTree
pub fn simplify_markers(&self, marker: MarkerTree) -> MarkerTree
Simplifies the given markers in such a way as to assume that the Python version is constrained by this Python version bound.
For example, with requires-python = '>=3.8', a marker like this:
python_full_version >= '3.8' and python_full_version < '3.12'Will be simplified to:
python_full_version < '3.12'That is, python_full_version >= '3.8' is assumed to be true by virtue
of requires-python, and is thus not needed in the marker.
This should be used in contexts in which this assumption is valid to
make. Generally, this means it should not be used inside the resolver,
but instead near the boundaries of the system (like formatting error
messages and writing the lock file). The reason for this is that
this simplification fundamentally changes the meaning of the marker,
and the only correct way to interpret it is in a context in which
requires-python is known to be true. For example, when markers from
a lock file are deserialized and turned into a ResolutionGraph, the
markers are “complexified” to put the requires-python assumption back
into the marker explicitly.
Sourcepub fn complexify_markers(&self, marker: MarkerTree) -> MarkerTree
pub fn complexify_markers(&self, marker: MarkerTree) -> MarkerTree
The inverse of simplify_markers.
This should be applied near the boundaries of uv when markers are
deserialized from a context where requires-python is assumed. For
example, with requires-python = '>=3.8' and a marker like:
python_full_version < '3.12'It will be “complexified” to:
python_full_version >= '3.8' and python_full_version < '3.12'Sourcepub fn matches_wheel_tag(&self, wheel: &WheelFilename) -> bool
pub fn matches_wheel_tag(&self, wheel: &WheelFilename) -> bool
Returns false if the wheel’s tags state it can’t be used in the given Python version
range.
It is meant to filter out clearly unusable wheels with perfect specificity and acceptable
sensitivity, we return true if the tags are unknown.
Trait Implementations§
Source§impl Clone for RequiresPython
impl Clone for RequiresPython
Source§fn clone(&self) -> RequiresPython
fn clone(&self) -> RequiresPython
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RequiresPython
impl Debug for RequiresPython
Source§impl<'de> Deserialize<'de> for RequiresPython
impl<'de> Deserialize<'de> for RequiresPython
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for RequiresPython
impl Display for RequiresPython
Source§impl Hash for RequiresPython
impl Hash for RequiresPython
Source§impl PartialEq for RequiresPython
impl PartialEq for RequiresPython
Source§impl Serialize for RequiresPython
impl Serialize for RequiresPython
impl Eq for RequiresPython
impl StructuralPartialEq for RequiresPython
Auto Trait Implementations§
impl Freeze for RequiresPython
impl RefUnwindSafe for RequiresPython
impl Send for RequiresPython
impl Sync for RequiresPython
impl Unpin for RequiresPython
impl UnwindSafe for RequiresPython
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.