Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix download --constraint for legacy-resolver. #9301

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/9283.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the download command when using --constraint with the legacy-resolver.
2 changes: 1 addition & 1 deletion src/pip/_internal/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def run(self, options, args):

downloaded = [] # type: List[str]
for req in requirement_set.requirements.values():
if req.satisfied_by is None:
if req.link and req.satisfied_by is None:
assert req.name is not None
preparer.save_linked_requirement(req)
downloaded.append(req.name)
Expand Down
19 changes: 19 additions & 0 deletions tests/functional/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ def test_download_wheel(script, data):
result.did_not_create(script.site_packages / 'piptestpackage')


def test_download_wheel_constraints(script, data):
"""
Test using "pip download" to download a *.whl with constraints.
"""
script.scratch_path.joinpath("constraints.txt").write_text(textwrap.dedent("""
meta==1.0
parent==0.1
"""))
result = script.pip(
'download',
'--no-index',
'-f', data.packages,
'-d', '.', 'meta',
'--constraint', script.scratch_path / 'constraints.txt',
)
result.did_create(Path('scratch') / 'meta-1.0-py2.py3-none-any.whl')
result.did_not_create(script.site_packages / 'piptestpackage')


@pytest.mark.network
def test_single_download_from_requirements_file(script):
"""
Expand Down