Expand description
A library for dependency specifiers previously known as PEP 508
§Usage
use std::str::FromStr;
use pep508_rs::{Requirement, VerbatimUrl, ExtraName};
let marker = r#"requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8""#;
let dependency_specification = Requirement::<VerbatimUrl>::from_str(marker).unwrap();
assert_eq!(dependency_specification.name.as_ref(), "requests");
assert_eq!(dependency_specification.extras, vec![ExtraName::from_str("security").unwrap(), ExtraName::from_str("tests").unwrap()]);Re-exports§
pub use marker::ContainsMarkerTree;pub use marker::ExtraMarkerTree;pub use marker::ExtraOperator;pub use marker::InMarkerTree;pub use marker::MarkerEnvironment;pub use marker::MarkerEnvironmentBuilder;pub use marker::MarkerExpression;pub use marker::MarkerOperator;pub use marker::MarkerTree;pub use marker::MarkerTreeContents;pub use marker::MarkerTreeKind;pub use marker::MarkerValue;pub use marker::MarkerValueExtra;pub use marker::MarkerValueString;pub use marker::MarkerValueVersion;pub use marker::MarkerWarningKind;pub use marker::StringMarkerTree;pub use marker::StringVersion;pub use marker::VersionMarkerTree;pub use pep440_rs;
Modules§
- marker
- PEP 508 markers implementations with validation and warnings
Structs§
- Extra
Name - The normalized name of an extra dependency group.
- Extras
- A list of
ExtraNamethat can be attached to aRequirement. - Invalid
Name Error - Invalid
crate::PackageNameorcrate::ExtraName. - Package
Name - The normalized name of a package.
- Pep508
Error - Error with a span attached. Not that those aren’t
StringbutVec<char>indices. - Requirement
- A PEP 508 dependency specifier.
- Tracing
Reporter - A simple
Reporterthat logs to tracing when thetracingfeature is enabled. - Verbatim
Url - A wrapper around
Urlthat preserves the original string.
Enums§
- Pep508
Error Source - Either we have an error string from our parser or an upstream error from
url - Requirement
Origin - The origin of a dependency, e.g., a
-r requirements.txtfile. - Scheme
- A supported URL scheme for PEP 508 direct-URL requirements.
- Verbatim
UrlError - An error that can occur when parsing a
VerbatimUrl. - Version
OrUrl - The actual version specifier or URL to install.
- Version
OrUrl Ref - Unowned version specifier or URL to install.
Traits§
- Pep508
Url - Type to parse URLs from
name @ <url>into. Defaults tourl::Url. - Reporter
- A reporter for warnings that occur during marker parsing or evaluation.
Functions§
- expand_
env_ vars - Expand all available environment variables.
- split_
extras - Identify the extras in a relative URL (e.g.,
../editable[dev]). - split_
scheme - Like
Url::parse, but only splits the scheme. Derived from theurlcrate. - strip_
host - Strip the
file://localhost/host from a file path.