Skip to content

A library for python dependency specifiers (PEP 508) with validations and warnings

License

Apache-2.0, BSD-2-Clause licenses found

Licenses found

Apache-2.0
License-Apache
BSD-2-Clause
License-BSD
Notifications You must be signed in to change notification settings

konstin/pep508_rs

Dependency specifiers (PEP 508) in Rust

Crates.io docs.rs

A library for python dependency specifiers, better known as PEP 508.

Usage

In Rust

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()]));

Markers

Markers allow you to install dependencies only in specific environments (python version, operating system, architecture, etc.) or when a specific feature is activated. E.g. you can say importlib-metadata ; python_version < "3.8" or itsdangerous (>=1.1.0) ; extra == 'security'. Unfortunately, the marker grammar has some oversights (e.g. pypa/packaging.python.org#1181) and the design of comparisons (PEP 440 comparisons with lexicographic fallback) leads to confusing outcomes. This implementation tries to carefully validate everything and emit warnings whenever bogus comparisons with unintended semantics are made.

About

A library for python dependency specifiers (PEP 508) with validations and warnings

Resources

License

Apache-2.0, BSD-2-Clause licenses found

Licenses found

Apache-2.0
License-Apache
BSD-2-Clause
License-BSD

Stars

Watchers

Forks

Packages

No packages published

Languages