Skip to content

Commit 5bfccfd

Browse files
committed
Report requested_extras for editable requirements
1 parent 2f27183 commit 5bfccfd

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def make_install_req_from_editable(
7979
link: Link, template: InstallRequirement
8080
) -> InstallRequirement:
8181
assert template.editable, "template not editable"
82-
return install_req_from_editable(
82+
ireq = install_req_from_editable(
8383
link.url,
8484
user_supplied=template.user_supplied,
8585
comes_from=template.comes_from,
@@ -91,6 +91,8 @@ def make_install_req_from_editable(
9191
hash_options=template.hash_options,
9292
config_settings=template.config_settings,
9393
)
94+
ireq.extras = template.extras
95+
return ireq
9496

9597

9698
def _make_install_req_from_dist(

tests/functional/test_install_report.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,52 @@ def test_install_report_local_path_with_extras(
224224
assert "requested_extras" not in simple_report
225225

226226

227+
@pytest.mark.network
228+
def test_install_report_editable_local_path_with_extras(
229+
script: PipTestEnvironment, tmp_path: Path, shared_data: TestData
230+
) -> None:
231+
"""Test report remote editable."""
232+
project_path = tmp_path / "pkga"
233+
project_path.mkdir()
234+
project_path.joinpath("pyproject.toml").write_text(
235+
textwrap.dedent(
236+
"""\
237+
[project]
238+
name = "pkga"
239+
version = "1.0"
240+
241+
[project.optional-dependencies]
242+
test = ["simple"]
243+
"""
244+
)
245+
)
246+
report_path = tmp_path / "report.json"
247+
script.pip(
248+
"install",
249+
"--dry-run",
250+
"--no-build-isolation",
251+
"--no-index",
252+
"--find-links",
253+
str(shared_data.root / "packages/"),
254+
"--report",
255+
str(report_path),
256+
"--editable",
257+
str(project_path) + "[test]",
258+
)
259+
report = json.loads(report_path.read_text())
260+
assert len(report["install"]) == 2
261+
pkga_report = report["install"][0]
262+
assert pkga_report["metadata"]["name"] == "pkga"
263+
assert pkga_report["is_direct"] is True
264+
assert pkga_report["requested"] is True
265+
assert pkga_report["requested_extras"] == ["test"]
266+
simple_report = report["install"][1]
267+
assert simple_report["metadata"]["name"] == "simple"
268+
assert simple_report["is_direct"] is False
269+
assert simple_report["requested"] is False
270+
assert "requested_extras" not in simple_report
271+
272+
227273
def test_install_report_to_stdout(
228274
script: PipTestEnvironment, shared_data: TestData
229275
) -> None:

0 commit comments

Comments
 (0)