mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
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:
parent
b8ef436c42
commit
0313e7d78b
14 changed files with 1078 additions and 1031 deletions
|
@ -205,4 +205,9 @@ impl RequirementSource {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the source is editable.
|
||||
pub fn is_editable(&self) -> bool {
|
||||
matches!(self, Self::Path { editable: true, .. })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,16 +59,9 @@ impl Resolution {
|
|||
self.0.is_empty()
|
||||
}
|
||||
|
||||
/// Return the set of [`Requirement`]s that this resolution represents, exclusive of any
|
||||
/// editable requirements.
|
||||
/// Return the set of [`Requirement`]s that this resolution represents.
|
||||
pub fn requirements(&self) -> Vec<Requirement> {
|
||||
let mut requirements: Vec<_> = self
|
||||
.0
|
||||
.values()
|
||||
// Remove editable requirements
|
||||
.filter(|dist| !dist.is_editable())
|
||||
.map(Requirement::from)
|
||||
.collect();
|
||||
let mut requirements: Vec<_> = self.0.values().map(Requirement::from).collect();
|
||||
requirements.sort_unstable_by(|a, b| a.name.cmp(&b.name));
|
||||
requirements
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue