Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/figsoda/pep-508

Rust implementation of Python dependency parser for PEP 508
https://github.com/figsoda/pep-508

chumsky parser pep508 python requirements rust

Last synced: 12 days ago
JSON representation

Rust implementation of Python dependency parser for PEP 508

Awesome Lists containing this project

README

        

# pep-508

Rust implementation of Python dependency parser for PEP 508

[![version](https://img.shields.io/crates/v/pep-508?logo=rust&style=flat-square)](https://crates.io/crates/pep-508)
[![deps](https://deps.rs/repo/github/figsoda/pep-508/status.svg?style=flat-square&compact=true)](https://deps.rs/repo/github/figsoda/pep-508)
[![license](https://img.shields.io/badge/license-MPL--2.0-blue?style=flat-square)](https://www.mozilla.org/en-US/MPL/2.0)
[![ci](https://img.shields.io/github/actions/workflow/status/figsoda/pep-508/ci.yml?label=ci&logo=github-actions&style=flat-square)](https://github.com/<>/actions/workflows/ci.yml)

[Documentation](https://docs.rs/pep-508)

## Usage

```rust
let dep = "requests[security, socks] <= 2.28.1, == 2.28.*; python_version > '3.7' and extra == 'http'";
let parsed = parse(dep).unwrap();
let expected = Dependency {
name: "requests",
extras: vec!["security", "socks"],
spec: Some(Spec::Version(vec![
VersionSpec {
comparator: Comparator::Le,
version: "2.28.1",
},
VersionSpec {
comparator: Comparator::Eq,
version: "2.28.*",
},
])),
marker: Some(Marker::And(
Box::new(Marker::Operator(
Variable::PythonVersion,
Operator::Comparator(Comparator::Gt),
Variable::String("3.7"),
)),
Box::new(Marker::Operator(
Variable::Extra,
Operator::Comparator(Comparator::Eq),
Variable::String("http"),
)),
)),
};
assert_eq!(parsed, expected);
```

## Changelog

See [CHANGELOG.md](CHANGELOG.md)