Error when workspace contains conflicting Python requirements (#10841)

## Summary

If members define disjoint Python requirements, we should error. Right
now, it seems that it maps to unbounded and leads to weird behavior.

Closes https://github.com/astral-sh/uv/issues/10835.
This commit is contained in:
Charlie Marsh 2025-01-22 12:22:52 -05:00 committed by GitHub
parent 1372c4e6de
commit 434706389b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 113 additions and 19 deletions

View file

@ -9,6 +9,7 @@ use tracing::{debug, trace, warn};
use uv_distribution_types::Index;
use uv_fs::{Simplified, CWD};
use uv_normalize::{GroupName, PackageName, DEV_DEPENDENCIES};
use uv_pep440::VersionSpecifiers;
use uv_pep508::{MarkerTree, VerbatimUrl};
use uv_pypi_types::{
Conflicts, Requirement, RequirementSource, SupportedEnvironments, VerbatimParsedUrl,
@ -383,6 +384,18 @@ impl Workspace {
conflicting
}
/// Returns an iterator over the `requires-python` values for each member of the workspace.
pub fn requires_python(&self) -> impl Iterator<Item = (&PackageName, &VersionSpecifiers)> {
self.packages().iter().filter_map(|(name, member)| {
member
.pyproject_toml()
.project
.as_ref()
.and_then(|project| project.requires_python.as_ref())
.map(|requires_python| (name, requires_python))
})
}
/// Returns any requirements that are exclusive to the workspace root, i.e., not included in
/// any of the workspace members.
///