Skip to content

Commit 2f27183

Browse files
committed
Report requested_extras for direct URLs
1 parent 55f1251 commit 2f27183

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

news/11946.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Correctly report ``requested_extras`` in the installation report when extras are
2+
specified for a local directory installation.

src/pip/_internal/resolution/resolvelib/candidates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def make_install_req_from_link(
7171
)
7272
ireq.original_link = template.original_link
7373
ireq.link = link
74+
ireq.extras = template.extras
7475
return ireq
7576

7677

tests/functional/test_install_report.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import textwrap
23
from pathlib import Path
34
from typing import Any, Dict
45

@@ -178,6 +179,51 @@ def test_install_report_vcs_editable(
178179
assert pip_test_package_report["download_info"]["dir_info"]["editable"] is True
179180

180181

182+
@pytest.mark.network
183+
def test_install_report_local_path_with_extras(
184+
script: PipTestEnvironment, tmp_path: Path, shared_data: TestData
185+
) -> None:
186+
"""Test report remote editable."""
187+
project_path = tmp_path / "pkga"
188+
project_path.mkdir()
189+
project_path.joinpath("pyproject.toml").write_text(
190+
textwrap.dedent(
191+
"""\
192+
[project]
193+
name = "pkga"
194+
version = "1.0"
195+
196+
[project.optional-dependencies]
197+
test = ["simple"]
198+
"""
199+
)
200+
)
201+
report_path = tmp_path / "report.json"
202+
script.pip(
203+
"install",
204+
"--dry-run",
205+
"--no-build-isolation",
206+
"--no-index",
207+
"--find-links",
208+
str(shared_data.root / "packages/"),
209+
"--report",
210+
str(report_path),
211+
str(project_path) + "[test]",
212+
)
213+
report = json.loads(report_path.read_text())
214+
assert len(report["install"]) == 2
215+
pkga_report = report["install"][0]
216+
assert pkga_report["metadata"]["name"] == "pkga"
217+
assert pkga_report["is_direct"] is True
218+
assert pkga_report["requested"] is True
219+
assert pkga_report["requested_extras"] == ["test"]
220+
simple_report = report["install"][1]
221+
assert simple_report["metadata"]["name"] == "simple"
222+
assert simple_report["is_direct"] is False
223+
assert simple_report["requested"] is False
224+
assert "requested_extras" not in simple_report
225+
226+
181227
def test_install_report_to_stdout(
182228
script: PipTestEnvironment, shared_data: TestData
183229
) -> None:

0 commit comments

Comments
 (0)