Skip to content

Commit d5df734

Browse files
committed
pip download: make sure that --use-pep517 is propagated to the dependencies
1 parent 3820b0e commit d5df734

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

news/9523.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Make the ``--use-pep517`` option of the ``download`` command apply not just
2+
to the requirements specified on the command line, but to their dependencies,
3+
as well.

src/pip/_internal/commands/download.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def run(self, options: Values, args: List[str]) -> int:
121121
finder=finder,
122122
options=options,
123123
ignore_requires_python=options.ignore_requires_python,
124+
use_pep517=options.use_pep517,
124125
py_version_info=options.python_version,
125126
)
126127

tests/functional/test_download.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
from pip._internal.cli.status_codes import ERROR
1010
from pip._internal.utils.urls import path_to_url
1111
from tests.conftest import MockServer, ScriptFactory
12-
from tests.lib import PipTestEnvironment, TestData, create_really_basic_wheel
12+
from tests.lib import (
13+
PipTestEnvironment,
14+
TestData,
15+
create_basic_sdist_for_package,
16+
create_really_basic_wheel,
17+
)
1318
from tests.lib.path import Path
1419
from tests.lib.server import file_response
1520

@@ -1163,3 +1168,35 @@ def test_download_editable(
11631168
downloads = os.listdir(download_dir)
11641169
assert len(downloads) == 1
11651170
assert downloads[0].endswith(".zip")
1171+
1172+
1173+
def test_download_use_pep517_propagation(
1174+
script: PipTestEnvironment, tmpdir: Path, common_wheels: Path
1175+
) -> None:
1176+
"""
1177+
Check that --use-pep517 applies not just to the requirements specified
1178+
on the command line, but to their dependencies too.
1179+
"""
1180+
1181+
# Remove setuptools to ensure that metadata retrieval fails unless PEP 517
1182+
# is used.
1183+
script.pip("uninstall", "-y", "setuptools")
1184+
1185+
create_basic_sdist_for_package(
1186+
script, "fake_proj", "1.0", setup_args={"install_requires": ["fake_dep"]}
1187+
)
1188+
create_basic_sdist_for_package(script, "fake_dep", "1.0")
1189+
1190+
download_dir = tmpdir / "download_dir"
1191+
script.pip(
1192+
"download",
1193+
f"--dest={download_dir}",
1194+
"--no-index",
1195+
f"--find-links={common_wheels}",
1196+
f"--find-links={script.scratch_path}",
1197+
"--use-pep517",
1198+
"fake_proj",
1199+
)
1200+
1201+
downloads = os.listdir(download_dir)
1202+
assert len(downloads) == 2

tests/lib/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ def create_basic_sdist_for_package(
11881188
*,
11891189
fails_egg_info: bool = False,
11901190
fails_bdist_wheel: bool = False,
1191+
setup_args: Optional[Dict[str, Any]] = None,
11911192
) -> Path:
11921193
files = {
11931194
"setup.py": f"""\
@@ -1203,7 +1204,7 @@ def create_basic_sdist_for_package(
12031204
if fails_bdist_wheel and "bdist_wheel" in sys.argv:
12041205
raise Exception("Simulated failure for building a wheel.")
12051206
1206-
setup(name={name!r}, version={version!r})
1207+
setup(name={name!r}, version={version!r}, **{setup_args or {}!r})
12071208
""",
12081209
}
12091210

0 commit comments

Comments
 (0)