Struct pep508_rs::Requirement
source · pub struct Requirement {
pub name: PackageName,
pub extras: Vec<ExtraName>,
pub version_or_url: Option<VersionOrUrl>,
pub marker: Option<MarkerTree>,
}
Expand description
A PEP 508 dependency specification
Fields§
§name: PackageName
The distribution name such as numpy
in
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8"
extras: Vec<ExtraName>
The list of extras such as security
, tests
in
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8"
version_or_url: Option<VersionOrUrl>
The version specifier such as >= 2.8.1
, == 2.8.*
in
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8"
or a url
marker: Option<MarkerTree>
The markers such as python_version > "3.8"
in
requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8"
.
Those are a nested and/or tree
Implementations§
source§impl Requirement
impl Requirement
sourcepub fn is_satisfied_by(&self, version: &Version) -> bool
pub fn is_satisfied_by(&self, version: &Version) -> bool
Returns true
if the Version
satisfies the Requirement
.
sourcepub fn evaluate_markers(
&self,
env: &MarkerEnvironment,
extras: &[ExtraName]
) -> bool
pub fn evaluate_markers( &self, env: &MarkerEnvironment, extras: &[ExtraName] ) -> bool
Returns whether the markers apply for the given environment
sourcepub fn evaluate_extras_and_python_version(
&self,
extras: &HashSet<ExtraName>,
python_versions: &[Version]
) -> bool
pub fn evaluate_extras_and_python_version( &self, extras: &HashSet<ExtraName>, python_versions: &[Version] ) -> bool
Returns whether the requirement would be satisfied, independent of environment markers, i.e. if there is potentially an environment that could activate this requirement.
Note that unlike Self::evaluate_markers
this does not perform any checks for bogus
expressions but will simply return true. As caller you should separately perform a check
with an environment and forward all warnings.
sourcepub fn evaluate_markers_and_report(
&self,
env: &MarkerEnvironment,
extras: &[ExtraName]
) -> (bool, Vec<(MarkerWarningKind, String, String)>)
pub fn evaluate_markers_and_report( &self, env: &MarkerEnvironment, extras: &[ExtraName] ) -> (bool, Vec<(MarkerWarningKind, String, String)>)
Returns whether the markers apply for the given environment
source§impl Requirement
impl Requirement
sourcepub fn parse(
input: &str,
working_dir: impl AsRef<Path>
) -> Result<Self, Pep508Error>
pub fn parse( input: &str, working_dir: impl AsRef<Path> ) -> Result<Self, Pep508Error>
Parse a Dependency Specifier
Trait Implementations§
source§impl Clone for Requirement
impl Clone for Requirement
source§fn clone(&self) -> Requirement
fn clone(&self) -> Requirement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Requirement
impl Debug for Requirement
source§impl Display for Requirement
impl Display for Requirement
source§impl FromStr for Requirement
impl FromStr for Requirement
§type Err = Pep508Error
type Err = Pep508Error
source§impl Hash for Requirement
impl Hash for Requirement
source§impl PartialEq for Requirement
impl PartialEq for Requirement
source§fn eq(&self, other: &Requirement) -> bool
fn eq(&self, other: &Requirement) -> bool
self
and other
values to be equal, and is used
by ==
.