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 17, 2022
1 parent 3820b0e commit d5df734
Show file tree
Hide file tree
Showing 4 changed files with 44 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
39 changes: 38 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,35 @@ 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", setup_args={"install_requires": ["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
3 changes: 2 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,
setup_args: Optional[Dict[str, Any]] = None,
) -> Path:
files = {
"setup.py": f"""\
Expand All @@ -1203,7 +1204,7 @@ 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}, **{setup_args or {}!r})
""",
}

Expand Down

0 comments on commit d5df734

Please sign in to comment.