From 3c62d1cbce9accf2dd6175bd83d82f34b6b2e04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 1 May 2022 12:41:47 +0200 Subject: [PATCH 1/2] Add failing test for REQUESTED and URL constraints --- tests/functional/test_install_requested.py | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/functional/test_install_requested.py b/tests/functional/test_install_requested.py index 0b5d5f18e..116933c10 100644 --- a/tests/functional/test_install_requested.py +++ b/tests/functional/test_install_requested.py @@ -110,3 +110,40 @@ def test_install_requested_in_reqs_and_constraints( _assert_requested_present(script, result, "require_simple", "1.0") # simple must have REQUESTED because it is in requirements.txt _assert_requested_present(script, result, "simple", "2.0") + + +@pytest.mark.usefixtures("with_wheel") +def test_install_requested_from_cli_with_constraint( + script: PipTestEnvironment, data: TestData +) -> None: + script.scratch_path.joinpath("constraints.txt").write_text("simple<3\n") + result = script.pip( + "install", + "--no-index", + "-f", + data.find_links, + "-c", + script.scratch_path / "constraints.txt", + "simple", + ) + # simple must have REQUESTED because it was provided on the command line + _assert_requested_present(script, result, "simple", "2.0") + + +@pytest.mark.usefixtures("with_wheel") +@pytest.mark.network +def test_install_requested_from_cli_with_url_constraint( + script: PipTestEnvironment, data: TestData +) -> None: + script.scratch_path.joinpath("constraints.txt").write_text( + "pip-test-package @ git+https://github.com/pypa/pip-test-package@0.1.1\n" + ) + result = script.pip( + "install", + "--no-index", + "-c", + script.scratch_path / "constraints.txt", + "pip-test-package", + ) + # pip-test-package must have REQUESTED because it was provided on the command line + _assert_requested_present(script, result, "pip_test_package", "0.1.1") From 52fd6436a252c08c5c9ce8f8dfed0fb477c8c5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 1 May 2022 19:40:16 +0200 Subject: [PATCH 2/2] Fix propagation of user_supplied with URL constrains --- news/11079.bugfix.rst | 1 + src/pip/_internal/req/constructors.py | 1 + 2 files changed, 2 insertions(+) create mode 100644 news/11079.bugfix.rst diff --git a/news/11079.bugfix.rst b/news/11079.bugfix.rst new file mode 100644 index 000000000..61305a765 --- /dev/null +++ b/news/11079.bugfix.rst @@ -0,0 +1 @@ +Fix missing ``REQUESTED`` metadata when using URL constraints. diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py index a879e94ea..dea7c3b01 100644 --- a/src/pip/_internal/req/constructors.py +++ b/src/pip/_internal/req/constructors.py @@ -497,4 +497,5 @@ def install_req_from_link_and_ireq( global_options=ireq.global_options, hash_options=ireq.hash_options, config_settings=ireq.config_settings, + user_supplied=ireq.user_supplied, )