Skip to content

Commit cf3696a

Browse files
authored
Merge pull request #11080 from sbidoul/requested-with-constraints
Fix REQUESTED in presence of URL constraints
2 parents bab5bfc + 52fd643 commit cf3696a

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

news/11079.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix missing ``REQUESTED`` metadata when using URL constraints.

src/pip/_internal/req/constructors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,5 @@ def install_req_from_link_and_ireq(
497497
global_options=ireq.global_options,
498498
hash_options=ireq.hash_options,
499499
config_settings=ireq.config_settings,
500+
user_supplied=ireq.user_supplied,
500501
)

tests/functional/test_install_requested.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,40 @@ def test_install_requested_in_reqs_and_constraints(
110110
_assert_requested_present(script, result, "require_simple", "1.0")
111111
# simple must have REQUESTED because it is in requirements.txt
112112
_assert_requested_present(script, result, "simple", "2.0")
113+
114+
115+
@pytest.mark.usefixtures("with_wheel")
116+
def test_install_requested_from_cli_with_constraint(
117+
script: PipTestEnvironment, data: TestData
118+
) -> None:
119+
script.scratch_path.joinpath("constraints.txt").write_text("simple<3\n")
120+
result = script.pip(
121+
"install",
122+
"--no-index",
123+
"-f",
124+
data.find_links,
125+
"-c",
126+
script.scratch_path / "constraints.txt",
127+
"simple",
128+
)
129+
# simple must have REQUESTED because it was provided on the command line
130+
_assert_requested_present(script, result, "simple", "2.0")
131+
132+
133+
@pytest.mark.usefixtures("with_wheel")
134+
@pytest.mark.network
135+
def test_install_requested_from_cli_with_url_constraint(
136+
script: PipTestEnvironment, data: TestData
137+
) -> None:
138+
script.scratch_path.joinpath("constraints.txt").write_text(
139+
"pip-test-package @ git+https://github.com/pypa/[email protected]\n"
140+
)
141+
result = script.pip(
142+
"install",
143+
"--no-index",
144+
"-c",
145+
script.scratch_path / "constraints.txt",
146+
"pip-test-package",
147+
)
148+
# pip-test-package must have REQUESTED because it was provided on the command line
149+
_assert_requested_present(script, result, "pip_test_package", "0.1.1")

0 commit comments

Comments
 (0)