diff options
author | Stéphane Bidoul <stephane.bidoul@gmail.com> | 2023-04-11 22:24:12 +0200 |
---|---|---|
committer | Stéphane Bidoul <stephane.bidoul@gmail.com> | 2023-04-11 22:24:12 +0200 |
commit | 5bfccfd62d6fab1600a655e1f9932335740bf593 (patch) | |
tree | 44711a414a67225df4b8712a86fb9c8709a7d330 | |
parent | 2f271838e7fb32930a7b21a35b9bbdc87a103f34 (diff) | |
download | pip-5bfccfd62d6fab1600a655e1f9932335740bf593.tar.gz |
Report requested_extras for editable requirements
-rw-r--r-- | src/pip/_internal/resolution/resolvelib/candidates.py | 4 | ||||
-rw-r--r-- | tests/functional/test_install_report.py | 46 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/pip/_internal/resolution/resolvelib/candidates.py b/src/pip/_internal/resolution/resolvelib/candidates.py index b1ff28288..39af0d5db 100644 --- a/src/pip/_internal/resolution/resolvelib/candidates.py +++ b/src/pip/_internal/resolution/resolvelib/candidates.py @@ -79,7 +79,7 @@ def make_install_req_from_editable( link: Link, template: InstallRequirement ) -> InstallRequirement: assert template.editable, "template not editable" - return install_req_from_editable( + ireq = install_req_from_editable( link.url, user_supplied=template.user_supplied, comes_from=template.comes_from, @@ -91,6 +91,8 @@ def make_install_req_from_editable( hash_options=template.hash_options, config_settings=template.config_settings, ) + ireq.extras = template.extras + return ireq def _make_install_req_from_dist( diff --git a/tests/functional/test_install_report.py b/tests/functional/test_install_report.py index e7fec8985..b8df6936f 100644 --- a/tests/functional/test_install_report.py +++ b/tests/functional/test_install_report.py @@ -224,6 +224,52 @@ def test_install_report_local_path_with_extras( assert "requested_extras" not in simple_report +@pytest.mark.network +def test_install_report_editable_local_path_with_extras( + script: PipTestEnvironment, tmp_path: Path, shared_data: TestData +) -> None: + """Test report remote editable.""" + project_path = tmp_path / "pkga" + project_path.mkdir() + project_path.joinpath("pyproject.toml").write_text( + textwrap.dedent( + """\ + [project] + name = "pkga" + version = "1.0" + + [project.optional-dependencies] + test = ["simple"] + """ + ) + ) + report_path = tmp_path / "report.json" + script.pip( + "install", + "--dry-run", + "--no-build-isolation", + "--no-index", + "--find-links", + str(shared_data.root / "packages/"), + "--report", + str(report_path), + "--editable", + str(project_path) + "[test]", + ) + report = json.loads(report_path.read_text()) + assert len(report["install"]) == 2 + pkga_report = report["install"][0] + assert pkga_report["metadata"]["name"] == "pkga" + assert pkga_report["is_direct"] is True + assert pkga_report["requested"] is True + assert pkga_report["requested_extras"] == ["test"] + simple_report = report["install"][1] + assert simple_report["metadata"]["name"] == "simple" + assert simple_report["is_direct"] is False + assert simple_report["requested"] is False + assert "requested_extras" not in simple_report + + def test_install_report_to_stdout( script: PipTestEnvironment, shared_data: TestData ) -> None: |