Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/6438.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support using ``--use-pep517`` and ``--no-use-pep517`` inside requirements
files for all packages installed.
4 changes: 4 additions & 0 deletions src/pip/_internal/req/req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
cmdoptions.constraints,
cmdoptions.requirements,
cmdoptions.editable,
cmdoptions.use_pep517,
cmdoptions.no_use_pep517,
cmdoptions.find_links,
cmdoptions.no_binary,
cmdoptions.only_binary,
Expand Down Expand Up @@ -239,6 +241,8 @@ def handle_option_line(
options.features_enabled.extend(
f for f in opts.features_enabled if f not in options.features_enabled
)
if opts.use_pep517 is not None:
options.use_pep517 = opts.use_pep517

# set finder options
if finder:
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def options(session: PipSession) -> mock.Mock:
index_url="default_url",
format_control=FormatControl(set(), set()),
features_enabled=[],
use_pep517=None,
)


Expand Down Expand Up @@ -675,6 +676,40 @@ def get_file_content(
assert result[0].name == req_name
assert not result[0].constraint

@pytest.mark.parametrize(
"use_pep517_cmd_line, line, expected",
[
# Test passing use_pep517=None.
(None, "", None),
(None, "--use-pep517", True),
(None, "--no-use-pep517", False),
# Test passing use_pep517=True.
(True, "", True),
(True, "--use-pep517", True),
(True, "--no-use-pep517", False),
# Test passing use_pep517=False.
(False, "", False),
(False, "--use-pep517", True),
(False, "--no-use-pep517", False),
],
)
def test_set_pep517_option_in_req_file(
self,
use_pep517_cmd_line: bool | None,
line: str,
expected: bool | None,
line_processor: LineProcessor,
options: mock.Mock,
) -> None:
"""
Test that using --use-pep517 or --no-use-pep517 in a requirements file
is both accepted and overrides the command line choices for that pep.
"""
filename = "filename"
options.use_pep517 = use_pep517_cmd_line
line_processor(line, filename, 1, options=options)
assert options.use_pep517 == expected


class TestBreakOptionsArgs:
def test_no_args(self) -> None:
Expand Down
Loading