Use common routines for pip install and pip sync (#3737)

## Summary

This PR takes the functions used in `pip install`, moves them into a
common module, and then replaces all the `pip sync` logic with calls
into those functions. The net effect is that `pip install` and `pip
sync` share far more code and demonstrate much more consistent behavior.

Closes https://github.com/astral-sh/uv/issues/3555.
This commit is contained in:
Charlie Marsh 2024-05-22 12:15:17 -04:00 committed by GitHub
parent b8ef436c42
commit 0313e7d78b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 1078 additions and 1031 deletions

View file

@ -139,7 +139,7 @@ impl Manifest {
// Include direct requirements, with constraints and overrides applied.
DependencyMode::Direct => Either::Right(
self.overrides.apply(& self.requirements)
self.overrides.apply(&self.requirements)
.chain(self.constraints.requirements())
.chain(self.overrides.requirements())
.filter(move |requirement| requirement.evaluate_markers(markers, &[]))),
@ -210,4 +210,9 @@ impl Manifest {
) -> impl Iterator<Item = &Requirement> {
self.constraints.apply(self.overrides.apply(requirements))
}
/// Returns the number of input requirements.
pub fn num_requirements(&self) -> usize {
self.requirements.len() + self.editables.len()
}
}