-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omit transitive development dependencies from workspace lockfile (#5646)
## Summary Omit development dependencies from (e.g.) path dependencies. Closes #5593.
- Loading branch information
1 parent
cbb13e6
commit 2574f5b
Showing
5 changed files
with
192 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use rustc_hash::FxHashMap; | ||
|
||
use pep508_rs::MarkerEnvironment; | ||
use uv_normalize::{GroupName, PackageName}; | ||
|
||
use crate::Manifest; | ||
|
||
/// A map of package names to their activated dependency groups. | ||
#[derive(Debug, Default, Clone)] | ||
pub(crate) struct Groups(FxHashMap<PackageName, Vec<GroupName>>); | ||
|
||
impl Groups { | ||
/// Determine the set of enabled dependency groups in the [`Manifest`]. | ||
pub(crate) fn from_manifest(manifest: &Manifest, markers: Option<&MarkerEnvironment>) -> Self { | ||
let mut groups = FxHashMap::default(); | ||
|
||
// Enable the groups for all direct dependencies. In practice, this tends to mean: when | ||
// development dependencies are enabled, enable them for all direct dependencies. | ||
for group in &manifest.dev { | ||
for requirement in manifest.direct_requirements(markers) { | ||
groups | ||
.entry(requirement.name.clone()) | ||
.or_insert_with(Vec::new) | ||
.push(group.clone()); | ||
} | ||
} | ||
|
||
Self(groups) | ||
} | ||
|
||
/// Retrieve the enabled dependency groups for a given package. | ||
pub(crate) fn get(&self, package: &PackageName) -> Option<&[GroupName]> { | ||
self.0.get(package).map(Vec::as_slice) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters