mirror of https://github.com/astral-sh/uv
Previously, `simplify_conflict_markers` assumed that it can remove all conflict set together, when we need to look at each conflict set individually. Specifically, `(platform_machine == 'x86_64' and extra == 'extra-5-foo-b') or extra == 'extra-5-foo-a'` can't be reduced `platform_machine == 'x86_64'` only because it reduces to true when both conflict extras are activated. This case applied in https://github.com/astral-sh/uv/issues/14805, where a jax 0.5.3 version was used for `platform_machine != 'aarch64' or sys_platform != 'linux'` and the conflict extra `cu128`, but jax 0.7.0 for the conflict extra `cpu`. Only removing the faulty inference regresses lockfiles to much more verbose markers. To balance the much more conservative inference, I added `unify_inference_sets` to simplify cases where all conflict branches reduce to the same marker. This still regresses some markers. For example `sys_platform == 'win32'` regresses to `sys_platform == 'win32' or (extra == 'extra-3-pkg-x1' and extra == 'extra-3-pkg-x2')` in `extra_inferences`, even through x1 and x2 conflict and the second conjunction could be simplified away. Fixes https://github.com/astral-sh/uv/issues/14805 |
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| Changelog.md | ||
| License-Apache | ||
| License-BSD | ||
| Readme.md | ||
Readme.md
Dependency specifiers (PEP 508) in Rust
A library for dependency specifiers, previously known as PEP 508.
Usage
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.
https://github.com/pypa/packaging.python.org/pull/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.