Enforce Requires-Python when syncing (#4068)

## Summary

Ensures that we raise if the user attempts to use a Python version that
wasn't included in the locked range.

Closes https://github.com/astral-sh/uv/issues/4052.
This commit is contained in:
Charlie Marsh 2024-06-05 16:22:08 -04:00 committed by GitHub
parent 642cef0dad
commit 0b6d5b37dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 199 additions and 5 deletions

View file

@ -113,6 +113,11 @@ impl Lock {
&self.distributions
}
/// Returns the supported Python version range for the lockfile, if present.
pub fn requires_python(&self) -> Option<&VersionSpecifiers> {
self.requires_python.as_ref()
}
/// Convert the [`Lock`] to a [`Resolution`] using the given marker environment, tags, and root.
pub fn to_resolution(
&self,