Expand description
A library for dependency specifiers previously known as PEP 508
§Usage
use std::str::FromStr;
use uv_pep508::{Requirement, VerbatimUrl};
use uv_normalize::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()].into());Re-exports§
pub use crate::marker::CanonicalMarkerValueExtra;pub use crate::marker::CanonicalMarkerValueString;pub use crate::marker::CanonicalMarkerValueVersion;pub use crate::marker::ContainsMarkerTree;pub use crate::marker::ExtraMarkerTree;pub use crate::marker::ExtraOperator;pub use crate::marker::InMarkerTree;pub use crate::marker::MarkerEnvironment;pub use crate::marker::MarkerEnvironmentBuilder;pub use crate::marker::MarkerExpression;pub use crate::marker::MarkerOperator;pub use crate::marker::MarkerTree;pub use crate::marker::MarkerTreeContents;pub use crate::marker::MarkerTreeKind;pub use crate::marker::MarkerValue;pub use crate::marker::MarkerValueExtra;pub use crate::marker::MarkerValueList;pub use crate::marker::MarkerValueString;pub use crate::marker::MarkerValueVersion;pub use crate::marker::MarkerWarningKind;pub use crate::marker::StringMarkerTree;pub use crate::marker::StringVersion;pub use crate::marker::VersionMarkerTree;pub use uv_pep440;
Modules§
- marker
- PEP 508 markers implementations with validation and warnings
Structs§
- Extras
- A list of
ExtraNamethat can be attached to aRequirement. - 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. - Reporter
- A reporter for warnings that occur during marker parsing or evaluation.
Functions§
- expand_
env_ vars - Expand all available environment variables.
- looks_
like_ git_ repository - Returns
trueif a URL looks like a reference to a Git repository (e.g.,https://github.com/user/repo.git). - 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.