Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/konstin/pep508_rs
A library for python dependency specifiers (PEP 508) with validations and warnings
https://github.com/konstin/pep508_rs
Last synced: 4 days ago
JSON representation
A library for python dependency specifiers (PEP 508) with validations and warnings
- Host: GitHub
- URL: https://github.com/konstin/pep508_rs
- Owner: konstin
- License: apache-2.0
- Created: 2023-03-06T12:25:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T08:39:48.000Z (2 months ago)
- Last Synced: 2024-10-25T05:14:28.898Z (2 months ago)
- Language: Rust
- Size: 173 KB
- Stars: 17
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- Changelog: Changelog.md
- License: License-Apache
Awesome Lists containing this project
README
# Dependency specifiers (PEP 508) in Rust
[![Crates.io](https://img.shields.io/crates/v/pep508_rs.svg?logo=rust&style=flat-square)](https://crates.io/crates/pep508_rs)
[![docs.rs](https://img.shields.io/docsrs/pep508_rs?style=flat-square)](https://docs.rs/pep508_rs)A library for python [dependency specifiers](https://packaging.python.org/en/latest/specifications/dependency-specifiers/), better known as [PEP 508](https://peps.python.org/pep-0508/).
## Usage
**In Rust**
```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. ) 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.