Skip to content

Commit b3de128

Browse files
committed
Support --group on pip wheel
Per review, support on `pip wheel` is desirable. This is net-net simpler, since we don't need any trickery to "dodge" the fact that it is a `RequirementCommand` but wasn't supporting `--group`. The desire to *not* support `--group` here was based on a mistaken idea about what `pip wheel` does.
1 parent f7ac91b commit b3de128

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

src/pip/_internal/cli/req_command.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class RequirementCommand(IndexGroupCommand):
8080
def __init__(self, *args: Any, **kw: Any) -> None:
8181
super().__init__(*args, **kw)
8282

83+
self.cmd_opts.add_option(cmdoptions.dependency_groups())
8384
self.cmd_opts.add_option(cmdoptions.no_clean())
8485

8586
@staticmethod

src/pip/_internal/commands/download.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class DownloadCommand(RequirementCommand):
3838
def add_options(self) -> None:
3939
self.cmd_opts.add_option(cmdoptions.constraints())
4040
self.cmd_opts.add_option(cmdoptions.requirements())
41-
self.cmd_opts.add_option(cmdoptions.dependency_groups())
4241
self.cmd_opts.add_option(cmdoptions.no_deps())
4342
self.cmd_opts.add_option(cmdoptions.global_options())
4443
self.cmd_opts.add_option(cmdoptions.no_binary())

src/pip/_internal/commands/install.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ def add_options(self) -> None:
8484
self.cmd_opts.add_option(cmdoptions.pre())
8585

8686
self.cmd_opts.add_option(cmdoptions.editable())
87-
self.cmd_opts.add_option(cmdoptions.dependency_groups())
8887
self.cmd_opts.add_option(
8988
"--dry-run",
9089
action="store_true",

src/pip/_internal/commands/wheel.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ def add_options(self) -> None:
102102

103103
@with_cleanup
104104
def run(self, options: Values, args: List[str]) -> int:
105-
# dependency-groups aren't desirable with `pip wheel`, but providing it
106-
# consistently allows RequirementCommand to expect it to be present
107-
options.dependency_groups = []
108-
109105
session = self.get_default_session(options)
110106

111107
finder = self._build_package_finder(options, session)

tests/functional/test_wheel.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import re
55
import sys
6+
import textwrap
67
from pathlib import Path
78

89
import pytest
@@ -69,6 +70,41 @@ def test_pip_wheel_success(script: PipTestEnvironment, data: TestData) -> None:
6970
assert "Successfully built simple" in result.stdout, result.stdout
7071

7172

73+
def test_pip_wheel_success_with_dependency_group(
74+
script: PipTestEnvironment, data: TestData
75+
) -> None:
76+
"""
77+
Test 'pip wheel' success.
78+
"""
79+
pyproject = script.scratch_path / "pyproject.toml"
80+
pyproject.write_text(
81+
textwrap.dedent(
82+
"""\
83+
[dependency-groups]
84+
simple = ["simple==3.0"]
85+
"""
86+
)
87+
)
88+
result = script.pip(
89+
"wheel",
90+
"--no-index",
91+
"-f",
92+
data.find_links,
93+
"--group",
94+
"simple",
95+
)
96+
wheel_file_name = f"simple-3.0-py{pyversion[0]}-none-any.whl"
97+
wheel_file_path = script.scratch / wheel_file_name
98+
assert re.search(
99+
r"Created wheel for simple: "
100+
rf"filename={re.escape(wheel_file_name)} size=\d+ sha256=[A-Fa-f0-9]{{64}}",
101+
result.stdout,
102+
)
103+
assert re.search(r"^\s+Stored in directory: ", result.stdout, re.M)
104+
result.did_create(wheel_file_path)
105+
assert "Successfully built simple" in result.stdout, result.stdout
106+
107+
72108
def test_pip_wheel_build_cache(script: PipTestEnvironment, data: TestData) -> None:
73109
"""
74110
Test 'pip wheel' builds and caches.

0 commit comments

Comments
 (0)