Rust implementation of Python dependency parser for PEP 508
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".to_owned(),
extras: vec!["security".to_owned(), "socks".to_owned()],
spec: Some(Spec::Version(vec![
VersionSpec {
comparator: Comparator::Le,
version: "2.28.1".to_owned(),
},
VersionSpec {
comparator: Comparator::Eq,
version: "2.28.*".to_owned(),
},
])),
marker: Some(Marker::And(
Box::new(Marker::Operator(
Variable::PythonVersion,
Operator::Comparator(Comparator::Gt),
Variable::String("3.7".to_owned()),
)),
Box::new(Marker::Operator(
Variable::Extra,
Operator::Comparator(Comparator::Eq),
Variable::String("http".to_owned()),
)),
)),
};
See CHANGELOG.md