temporarily disable new uv pip dependency-group flags (#10909)

We'll probably end up shipping but we were moving ahead with this on the
basis that pip may not even ship this, so let's play it safe and wait
for a bit.
This commit is contained in:
Aria Desires 2025-01-23 15:43:07 -05:00 committed by GitHub
parent 86f2f16d05
commit c05aca61db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 5 additions and 1064 deletions

View file

@ -1014,40 +1014,6 @@ pub struct PipCompileArgs {
#[arg(long, overrides_with("all_extras"), hide = true)]
pub no_all_extras: bool,
/// Include dependencies from the specified dependency group.
///
/// Only applies to `pyproject.toml` sources.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("only_group"))]
pub group: Vec<GroupName>,
/// Exclude dependencies from the specified dependency group.
///
/// Only applies to `pyproject.toml` sources.
///
/// May be provided multiple times.
#[arg(long)]
pub no_group: Vec<GroupName>,
/// Only include dependencies from the specified dependency group.
///
/// The project itself will also be omitted.
///
/// Only applies to `pyproject.toml` sources.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("group"))]
pub only_group: Vec<GroupName>,
/// Include dependencies from all dependency groups.
///
/// Only applies to `pyproject.toml` sources.
///
/// `--no-group` can be used to exclude specific groups.
#[arg(long, conflicts_with_all = [ "group", "only_group" ])]
pub all_groups: bool,
#[command(flatten)]
pub resolver: ResolverArgs,
@ -1606,40 +1572,6 @@ pub struct PipInstallArgs {
#[arg(long, overrides_with("all_extras"), hide = true)]
pub no_all_extras: bool,
/// Include dependencies from the specified dependency group.
///
/// Only applies to `pyproject.toml` sources.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("only_group"))]
pub group: Vec<GroupName>,
/// Exclude dependencies from the specified dependency group.
///
/// Only applies to `pyproject.toml` sources.
///
/// May be provided multiple times.
#[arg(long)]
pub no_group: Vec<GroupName>,
/// Only include dependencies from the specified dependency group.
///
/// The project itself will also be omitted.
///
/// Only applies to `pyproject.toml` sources.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("group"))]
pub only_group: Vec<GroupName>,
/// Include dependencies from all dependency groups.
///
/// Only applies to `pyproject.toml` sources.
///
/// `--no-group` can be used to exclude specific groups.
#[arg(long, conflicts_with_all = [ "group", "only_group" ])]
pub all_groups: bool,
#[command(flatten)]
pub installer: ResolverInstallerArgs,

View file

@ -13,7 +13,7 @@ use uv_distribution_types::{
};
use uv_install_wheel::linker::LinkMode;
use uv_macros::{CombineOptions, OptionsMetadata};
use uv_normalize::{ExtraName, GroupName, PackageName};
use uv_normalize::{ExtraName, PackageName};
use uv_pep508::Requirement;
use uv_pypi_types::{SupportedEnvironments, VerbatimParsedUrl};
use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
@ -1111,50 +1111,6 @@ pub struct PipOptions {
"#
)]
pub no_extra: Option<Vec<ExtraName>>,
/// Include optional dependencies from the specified group; may be provided more than once.
///
/// Only applies to `pyproject.toml` sources.
#[option(
default = "[]",
value_type = "list[str]",
example = r#"
group = ["dev", "docs"]
"#
)]
pub group: Option<Vec<GroupName>>,
/// Exclude optional dependencies from the specified group if `all-groups` are supplied
///
/// Only applies to `pyproject.toml` sources.
#[option(
default = "[]",
value_type = "list[str]",
example = r#"
no-group = ["dev", "docs"]
"#
)]
pub no_group: Option<Vec<GroupName>>,
/// Exclude only dependencies from the specified group.
///
/// Only applies to `pyproject.toml` sources.
#[option(
default = "[]",
value_type = "list[str]",
example = r#"
only-group = ["dev", "docs"]
"#
)]
pub only_group: Option<Vec<GroupName>>,
/// Include all groups.
///
/// Only applies to `pyproject.toml` sources.
#[option(
default = "false",
value_type = "bool",
example = r#"
all-groups = true
"#
)]
pub all_groups: Option<bool>,
/// Ignore package dependencies, instead only add those packages explicitly listed
/// on the command line to the resulting the requirements file.
#[option(

View file

@ -1513,10 +1513,6 @@ impl PipCompileSettings {
extra,
all_extras,
no_all_extras,
group,
no_group,
only_group,
all_groups,
build_constraints,
refresh,
no_deps,
@ -1621,10 +1617,6 @@ impl PipCompileSettings {
only_binary,
extra,
all_extras: flag(all_extras, no_all_extras),
group: Some(group),
no_group: Some(no_group),
only_group: Some(only_group),
all_groups: Some(all_groups),
no_deps: flag(no_deps, deps),
output_file,
no_strip_extras: flag(no_strip_extras, strip_extras),
@ -1767,10 +1759,6 @@ impl PipInstallSettings {
extra,
all_extras,
no_all_extras,
group,
no_group,
only_group,
all_groups,
installer,
refresh,
no_deps,
@ -1866,10 +1854,6 @@ impl PipInstallSettings {
strict: flag(strict, no_strict),
extra,
all_extras: flag(all_extras, no_all_extras),
group: Some(group),
no_group: Some(no_group),
only_group: Some(only_group),
all_groups: Some(all_groups),
no_deps: flag(no_deps, deps),
python_version,
python_platform,
@ -2655,10 +2639,6 @@ impl PipSettings {
extra,
all_extras,
no_extra,
group,
no_group,
only_group,
all_groups,
no_deps,
allow_empty_requirements,
resolution,
@ -2780,11 +2760,11 @@ impl PipSettings {
false,
false,
false,
args.group.combine(group).unwrap_or_default(),
args.no_group.combine(no_group).unwrap_or_default(),
Vec::new(),
Vec::new(),
false,
Vec::new(),
false,
args.only_group.combine(only_group).unwrap_or_default(),
args.all_groups.combine(all_groups).unwrap_or_default(),
),
dependency_mode: if args.no_deps.combine(no_deps).unwrap_or_default() {
DependencyMode::Direct

View file

@ -14430,295 +14430,3 @@ fn respect_index_preference() -> Result<()> {
Ok(())
}
#[test]
fn dependency_group() -> Result<()> {
fn new_context() -> Result<TestContext> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["typing-extensions"]
[dependency-groups]
foo = ["sortedcontainers"]
bar = ["iniconfig"]
dev = ["sniffio"]
"#,
)?;
Ok(context)
}
let mut context;
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 1 package in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("--only-group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
# 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
----- stderr -----
Resolved 1 package in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("--group").arg("foo"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml --group foo
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 2 packages in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("--group").arg("foo")
.arg("--group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml --group foo --group bar
iniconfig==2.0.0
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 3 packages in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("--all-groups"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml --all-groups
iniconfig==2.0.0
sniffio==1.3.1
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 4 packages in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("--all-groups")
.arg("--no-group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml --all-groups --no-group bar
sniffio==1.3.1
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 3 packages in [TIME]
"###);
Ok(())
}
#[test]
fn many_pyproject_group() -> Result<()> {
fn new_context() -> Result<TestContext> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["typing-extensions"]
[dependency-groups]
foo = ["sortedcontainers"]
"#,
)?;
let subdir = context.temp_dir.child("subdir");
subdir.create_dir_all()?;
let pyproject_toml2 = subdir.child("pyproject.toml");
pyproject_toml2.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
[dependency-groups]
foo = ["iniconfig"]
bar = ["sniffio"]
"#,
)?;
Ok(context)
}
let mut context;
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("subdir/pyproject.toml"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml subdir/pyproject.toml
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 1 package in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("subdir/pyproject.toml")
.arg("--all-groups"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml subdir/pyproject.toml --all-groups
iniconfig==2.0.0
sniffio==1.3.1
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 4 packages in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("subdir/pyproject.toml")
.arg("--group").arg("foo"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml subdir/pyproject.toml --group foo
iniconfig==2.0.0
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
Resolved 3 packages in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("subdir/pyproject.toml")
.arg("--group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml subdir/pyproject.toml --group bar
sniffio==1.3.1
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
warning: The dependency-group 'bar' is not defined in pyproject.toml
Resolved 2 packages in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters().into_iter().chain([(
"warning: The dependency-group 'lies' is not defined in pyproject.toml\nwarning: The dependency-group 'lies' is not defined in subdir/pyproject.toml",
"warning: The dependency-group 'lies' is not defined in subdir/pyproject.toml\nwarning: The dependency-group 'lies' is not defined in pyproject.toml",
)]).collect::<Vec<_>>(), context.pip_compile()
.arg("pyproject.toml")
.arg("subdir/pyproject.toml")
.arg("--group").arg("lies"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml subdir/pyproject.toml --group lies
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
warning: The dependency-group 'lies' is not defined in subdir/pyproject.toml
warning: The dependency-group 'lies' is not defined in pyproject.toml
Resolved 1 package in [TIME]
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_compile()
.arg("pyproject.toml")
.arg("subdir/pyproject.toml")
.arg("--group").arg("foo")
.arg("--group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
# This file was autogenerated by uv via the following command:
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml subdir/pyproject.toml --group foo --group bar
iniconfig==2.0.0
sniffio==1.3.1
sortedcontainers==2.4.0
typing-extensions==4.10.0
# via project (pyproject.toml)
----- stderr -----
warning: The dependency-group 'bar' is not defined in pyproject.toml
Resolved 4 packages in [TIME]
"###);
Ok(())
}

View file

@ -8374,437 +8374,3 @@ fn direct_url_json_direct_url() -> Result<()> {
Ok(())
}
#[test]
fn dependency_group() -> Result<()> {
fn new_context() -> Result<TestContext> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["typing-extensions"]
[dependency-groups]
foo = ["sortedcontainers"]
bar = ["iniconfig"]
dev = ["sniffio"]
"#,
)?;
context.lock().assert().success();
Ok(context)
}
let mut context;
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("--only-group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ iniconfig==2.0.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("--group").arg("foo"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 2 packages in [TIME]
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("--group").arg("foo")
.arg("--group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 3 packages in [TIME]
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
+ iniconfig==2.0.0
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("--all-groups"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 4 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ iniconfig==2.0.0
+ sniffio==1.3.1
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("--all-groups")
.arg("--no-group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 3 packages in [TIME]
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
+ sniffio==1.3.1
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
Ok(())
}
#[test]
fn dependency_group_default_groups() -> Result<()> {
fn new_context() -> Result<TestContext> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["typing-extensions"]
[tool.uv]
default-groups = ["foo", "bar"]
[dependency-groups]
foo = ["sortedcontainers"]
bar = ["iniconfig"]
dev = ["sniffio"]
"#,
)?;
context.lock().assert().success();
Ok(context)
}
let mut context;
// We should not install the default groups
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ typing-extensions==4.10.0
"###);
// Selecting a group works as normal
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("--only-group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ iniconfig==2.0.0
"###);
Ok(())
}
#[test]
fn many_pyproject_group() -> Result<()> {
fn new_context() -> Result<TestContext> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["typing-extensions"]
[dependency-groups]
foo = ["sortedcontainers"]
"#,
)?;
let subdir = context.temp_dir.child("subdir");
subdir.create_dir_all()?;
let pyproject_toml2 = subdir.child("pyproject.toml");
pyproject_toml2.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
[dependency-groups]
foo = ["iniconfig"]
bar = ["sniffio"]
"#,
)?;
context.lock().assert().success();
Ok(context)
}
let mut context;
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("-r").arg("subdir/pyproject.toml"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("-r").arg("subdir/pyproject.toml")
.arg("--all-groups"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 4 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ iniconfig==2.0.0
+ sniffio==1.3.1
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("-r").arg("subdir/pyproject.toml")
.arg("--group").arg("foo"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 3 packages in [TIME]
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
+ iniconfig==2.0.0
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("-r").arg("subdir/pyproject.toml")
.arg("--group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: The dependency-group 'bar' is not defined in pyproject.toml
Resolved 2 packages in [TIME]
Prepared 2 packages in [TIME]
Installed 2 packages in [TIME]
+ sniffio==1.3.1
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters().into_iter().chain([(
"warning: The dependency-group 'lies' is not defined in pyproject.toml\nwarning: The dependency-group 'lies' is not defined in subdir/pyproject.toml",
"warning: The dependency-group 'lies' is not defined in subdir/pyproject.toml\nwarning: The dependency-group 'lies' is not defined in pyproject.toml",
)]).collect::<Vec<_>>(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("-r").arg("subdir/pyproject.toml")
.arg("--group").arg("lies"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: The dependency-group 'lies' is not defined in subdir/pyproject.toml
warning: The dependency-group 'lies' is not defined in pyproject.toml
Resolved 1 package in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ typing-extensions==4.10.0
"###);
context = new_context()?;
uv_snapshot!(context.filters(), context.pip_install()
.arg("-r").arg("pyproject.toml")
.arg("-r").arg("subdir/pyproject.toml")
.arg("--group").arg("foo")
.arg("--group").arg("bar"), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
warning: The dependency-group 'bar' is not defined in pyproject.toml
Resolved 4 packages in [TIME]
Prepared 4 packages in [TIME]
Installed 4 packages in [TIME]
+ iniconfig==2.0.0
+ sniffio==1.3.1
+ sortedcontainers==2.4.0
+ typing-extensions==4.10.0
"###);
Ok(())
}
#[test]
fn group_needs_manifest() {
let context = TestContext::new("3.12");
uv_snapshot!(context.filters(), context.pip_install()
.arg("sniffio")
.arg("--group").arg("foo"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: Requesting groups requires a `pyproject.toml`.
"###);
}
#[test]
fn group_directory_target() -> Result<()> {
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["typing-extensions"]
[dependency-groups]
foo = ["sortedcontainers"]
"#,
)?;
let subdir = context.temp_dir.child("subdir");
subdir.create_dir_all()?;
let pyproject_toml2 = subdir.child("pyproject.toml");
pyproject_toml2.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
[dependency-groups]
foo = ["iniconfig"]
bar = ["sniffio"]
"#,
)?;
context.lock().assert().success();
// Targeting a directory does not allow selection of groups
uv_snapshot!(context.filters(), context.pip_install().arg(".").arg("--group").arg("foo"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: Requesting groups requires a `pyproject.toml`.
"###);
// A subdirectory is the same
uv_snapshot!(context.filters(), context.pip_install().arg("subdir").arg("--group").arg("foo"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: Requesting groups requires a `pyproject.toml`.
"###);
// Editables are the same
uv_snapshot!(context.filters(), context.pip_install().arg("-e").arg(".").arg("--group").arg("foo"), @r###"
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: Requesting groups requires a `pyproject.toml`.
"###);
Ok(())
}