Skip to content

Commit

Permalink
pip download: make sure that --use-pep517 is propagated to the depend…
Browse files Browse the repository at this point in the history
…encies
  • Loading branch information
SpecLad committed Apr 18, 2022
1 parent 3820b0e commit e3be557
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions news/9523.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Make the ``--use-pep517`` option of the ``download`` command apply not just
to the requirements specified on the command line, but to their dependencies,
as well.
1 change: 1 addition & 0 deletions src/pip/_internal/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def run(self, options: Values, args: List[str]) -> int:
finder=finder,
options=options,
ignore_requires_python=options.ignore_requires_python,
use_pep517=options.use_pep517,
py_version_info=options.python_version,
)

Expand Down
37 changes: 36 additions & 1 deletion tests/functional/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from pip._internal.cli.status_codes import ERROR
from pip._internal.utils.urls import path_to_url
from tests.conftest import MockServer, ScriptFactory
from tests.lib import PipTestEnvironment, TestData, create_really_basic_wheel
from tests.lib import (
PipTestEnvironment,
TestData,
create_basic_sdist_for_package,
create_really_basic_wheel,
)
from tests.lib.path import Path
from tests.lib.server import file_response

Expand Down Expand Up @@ -1163,3 +1168,33 @@ def test_download_editable(
downloads = os.listdir(download_dir)
assert len(downloads) == 1
assert downloads[0].endswith(".zip")


def test_download_use_pep517_propagation(
script: PipTestEnvironment, tmpdir: Path, common_wheels: Path
) -> None:
"""
Check that --use-pep517 applies not just to the requirements specified
on the command line, but to their dependencies too.
"""

# Remove setuptools to ensure that metadata retrieval fails unless PEP 517
# is used.
script.pip("uninstall", "-y", "setuptools")

create_basic_sdist_for_package(script, "fake_proj", "1.0", depends=["fake_dep"])
create_basic_sdist_for_package(script, "fake_dep", "1.0")

download_dir = tmpdir / "download_dir"
script.pip(
"download",
f"--dest={download_dir}",
"--no-index",
f"--find-links={common_wheels}",
f"--find-links={script.scratch_path}",
"--use-pep517",
"fake_proj",
)

downloads = os.listdir(download_dir)
assert len(downloads) == 2
4 changes: 3 additions & 1 deletion tests/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,7 @@ def create_basic_sdist_for_package(
*,
fails_egg_info: bool = False,
fails_bdist_wheel: bool = False,
depends: Optional[List[str]] = None,
) -> Path:
files = {
"setup.py": f"""\
Expand All @@ -1203,7 +1204,8 @@ def create_basic_sdist_for_package(
if fails_bdist_wheel and "bdist_wheel" in sys.argv:
raise Exception("Simulated failure for building a wheel.")
setup(name={name!r}, version={version!r})
setup(name={name!r}, version={version!r},
install_requires={depends or []!r})
""",
}

Expand Down

0 comments on commit e3be557

Please sign in to comment.