Skip to content

Commit e3be557

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

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
@@ -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: 36 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,33 @@ 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(script, "fake_proj", "1.0", depends=["fake_dep"])
1186+
create_basic_sdist_for_package(script, "fake_dep", "1.0")
1187+
1188+
download_dir = tmpdir / "download_dir"
1189+
script.pip(
1190+
"download",
1191+
f"--dest={download_dir}",
1192+
"--no-index",
1193+
f"--find-links={common_wheels}",
1194+
f"--find-links={script.scratch_path}",
1195+
"--use-pep517",
1196+
"fake_proj",
1197+
)
1198+
1199+
downloads = os.listdir(download_dir)
1200+
assert len(downloads) == 2

tests/lib/__init__.py

Lines changed: 3 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+
depends: Optional[List[str]] = None,
11911192
) -> Path:
11921193
files = {
11931194
"setup.py": f"""\
@@ -1203,7 +1204,8 @@ 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},
1208+
install_requires={depends or []!r})
12071209
""",
12081210
}
12091211

0 commit comments

Comments
 (0)