fix `--only-group` in `uv pip` interface (#10902)

This was an oversight in the implementation, thankfully it appears to be
a simple fix? (My only hesitation is this implementation essentially
claims that --only-group is defacto incompatible with --extra and I
*think* that's the case but I'm not certain.)
This commit is contained in:
Aria Desires 2025-01-23 11:35:47 -05:00 committed by GitHub
parent 8ce0736f9e
commit 214494149c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 17 deletions

View File

@ -98,16 +98,21 @@ impl<'a, Context: BuildContext> SourceTreeResolver<'a, Context> {
.cloned()
.collect::<Vec<_>>();
// Flatten any transitive extras.
let mut requirements =
let mut requirements = Vec::new();
// Flatten any transitive extras and include dependencies
// (unless something like --only-group was passed)
if self.groups.prod() {
requirements.extend(
FlatRequiresDist::from_requirements(metadata.requires_dist, &metadata.name)
.into_iter()
.map(|requirement| Requirement {
origin: Some(origin.clone()),
marker: requirement.marker.simplify_extras(&extras),
..requirement
})
.collect::<Vec<_>>();
}),
);
}
// Apply dependency-groups
for (group_name, group) in &metadata.dependency_groups {

View File

@ -14481,11 +14481,9 @@ fn dependency_group() -> Result<()> {
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml --only-group bar
iniconfig==2.0.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 2 packages in [TIME]
Resolved 1 package in [TIME]
"###);
context = new_context()?;

View File

@ -8425,11 +8425,10 @@ fn dependency_group() -> Result<()> {
----- stdout -----
----- stderr -----
Resolved 2 packages in [TIME]
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ iniconfig==2.0.0
+ typing-extensions==4.10.0
"###);
context = new_context()?;