-
Notifications
You must be signed in to change notification settings - Fork 2.9k
universal-lock: add marker evaluation for just extras #3352
Description
The central way that a universal lock file is generated is by ignoring the markers in a list of dependencies. For example, given:
foo>=3 ; sys_platform == 'linux'
foo<3 ; sys_platform == 'darwin'
then a universal lock file needs to be generated by considering both foo>=3 and foo<3. Normally, the marker expressions would cause these dependencies to be disjoint.
However, not all markers should be ignored. The extra marker, for example, should still be evaluated since it isn't directly dependent on the platform.
This ticket is thus about adding a new marker evaluation routine that only looks at platform independent markers:
uv/crates/pep508-rs/src/lib.rs
Lines 354 to 361 in e33ff95
| /// Returns whether the markers apply for the given environment | |
| pub fn evaluate_markers(&self, env: &MarkerEnvironment, extras: &[ExtraName]) -> bool { | |
| if let Some(marker) = &self.marker { | |
| marker.evaluate(env, extras) | |
| } else { | |
| true | |
| } | |
| } |
There does exist this routine:
uv/crates/pep508-rs/src/lib.rs
Lines 363 to 379 in e33ff95
| /// Returns whether the requirement would be satisfied, independent of environment markers, i.e. | |
| /// if there is potentially an environment that could activate this requirement. | |
| /// | |
| /// Note that unlike [`Self::evaluate_markers`] this does not perform any checks for bogus | |
| /// expressions but will simply return true. As caller you should separately perform a check | |
| /// with an environment and forward all warnings. | |
| pub fn evaluate_extras_and_python_version( | |
| &self, | |
| extras: &HashSet<ExtraName>, | |
| python_versions: &[Version], | |
| ) -> bool { | |
| if let Some(marker) = &self.marker { | |
| marker.evaluate_extras_and_python_version(extras, python_versions) | |
| } else { | |
| true | |
| } | |
| } |
But it also evaluates Python versions and its signature is a bit different.