Skip to content

Commit 6987847

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

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-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
@@ -122,6 +122,7 @@ def run(self, options: Values, args: List[str]) -> int:
122122
finder=finder,
123123
options=options,
124124
ignore_requires_python=options.ignore_requires_python,
125+
use_pep517=options.use_pep517,
125126
py_version_info=options.python_version,
126127
)
127128

tests/functional/test_download.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
from pip._internal.cli.status_codes import ERROR
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.server import file_response
1419

1520

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

tests/lib/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ def create_basic_sdist_for_package(
12111211
*,
12121212
fails_egg_info: bool = False,
12131213
fails_bdist_wheel: bool = False,
1214+
depends: Optional[List[str]] = None,
12141215
) -> pathlib.Path:
12151216
files = {
12161217
"setup.py": f"""\
@@ -1226,7 +1227,8 @@ def create_basic_sdist_for_package(
12261227
if fails_bdist_wheel and "bdist_wheel" in sys.argv:
12271228
raise Exception("Simulated failure for building a wheel.")
12281229
1229-
setup(name={name!r}, version={version!r})
1230+
setup(name={name!r}, version={version!r},
1231+
install_requires={depends or []!r})
12301232
""",
12311233
}
12321234

0 commit comments

Comments
 (0)