Crate pep508_rs

source ·
Expand description

A library for python dependency specifiers better known as PEP 508

Usage

use std::str::FromStr;
use pep508_rs::Requirement;

let marker = r#"requests [security,tests] >= 2.8.1, == 2.8.* ; python_version > "3.8""#;
let dependency_specification = Requirement::from_str(marker).unwrap();
assert_eq!(dependency_specification.name, "requests");
assert_eq!(dependency_specification.extras, Some(vec!["security".to_string(), "tests".to_string()]));

Structs

  • A Vec<char> and an index inside of it. Like String, but with utf-8 aware indexing
  • The marker values for a python interpreter, normally the current one
  • Represents one clause such as python_version > "3.8" in the form
  • Error with a span attached. Not that those aren’t String but Vec<char> indices.
  • A PEP 508 dependency specification
  • Helper type with a Version and its original text

Enums

  • How to compare key and value, such as by ==, > or not in
  • Represents one of the nested marker expressions with and/or/parentheses
  • One of the predefined environment values
  • Those environment markers with an arbitrary string as value such as sys_platform
  • Those environment markers with a PEP 440 version as value such as python_version
  • Ways in which marker evaluation can fail
  • Either we have an error string from our parser or an upstream error from url
  • The actual version specifier or url to install