Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/figsoda/pep-508
- Owner: figsoda
- License: mpl-2.0
- Created: 2023-02-17T03:42:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-08T03:54:18.000Z (7 months ago)
- Last Synced: 2024-10-30T00:23:54.512Z (15 days ago)
- Topics: chumsky, parser, pep508, python, requirements, rust
- Language: Rust
- Homepage: https://docs.rs/pep-508
- Size: 32.2 KB
- Stars: 23
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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)