Crate pep508_rs

Source
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§

ExtraName
The normalized name of an extra dependency group.
Extras
A list of ExtraName that can be attached to a Requirement.
InvalidNameError
Invalid crate::PackageName or crate::ExtraName.
PackageName
The normalized name of a package.
Pep508Error
Error with a span attached. Not that those aren’t String but Vec<char> indices.
Requirement
A PEP 508 dependency specifier.
TracingReporter
A simple Reporter that logs to tracing when the tracing feature is enabled.
VerbatimUrl
A wrapper around Url that preserves the original string.

Enums§

Pep508ErrorSource
Either we have an error string from our parser or an upstream error from url
RequirementOrigin
The origin of a dependency, e.g., a -r requirements.txt file.
Scheme
A supported URL scheme for PEP 508 direct-URL requirements.
VerbatimUrlError
An error that can occur when parsing a VerbatimUrl.
VersionOrUrl
The actual version specifier or URL to install.
VersionOrUrlRef
Unowned version specifier or URL to install.

Traits§

Pep508Url
Type to parse URLs from name @ <url> into. Defaults to url::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 the url crate.
strip_host
Strip the file://localhost/ host from a file path.