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

The download command using legacy-resolver fails for --constraint where the constraints are disjoint / a superset. #9283

Closed
jsirois opened this issue Dec 15, 2020 · 4 comments

Comments

@jsirois
Copy link
Contributor

jsirois commented Dec 15, 2020

Environment

  • pip version: 20.3.2
  • Python version: CPython 3.9
  • OS: Linux

Description
When --constraint is used and the constraints contain requirements not in the transitive closure of a download, the download command fails to filter out InstallRequirements that are constraint-only and thus have have no link resulting in an AssertionError.

Expected behavior
No error should occur.

How to Reproduce
Perform a download of a pinned requirement using a constraints file that only contains pinned requirements, one of which is disjoint with the set of transitive requirements of the original download subject requirement. The output demonstrates all this.

Output

$ pip --version
pip 20.3.2 from /home/jsirois/.local/lib/python3.9/site-packages/pip (python 3.9)
$ cat constraints.txt 
ansicolors==1.1.8
$ rm -rf wheels/ && pip download --dest wheels/ --use-deprecated legacy-resolver ansicolors==1.1.8 --constraint constraints.txt
Collecting ansicolors==1.1.8
  Using cached ansicolors-1.1.8-py2.py3-none-any.whl (13 kB)
Saved ./wheels/ansicolors-1.1.8-py2.py3-none-any.whl
Successfully downloaded ansicolors
$ echo pex==2.1.23 >> constraints.txt
$ cat constraints.txt 
ansicolors==1.1.8
pex==2.1.23
$ rm -rf wheels/ && pip download --dest wheels/ --use-deprecated legacy-resolver ansicolors==1.1.8 --constraint constraints.txt
Collecting ansicolors==1.1.8
  Using cached ansicolors-1.1.8-py2.py3-none-any.whl (13 kB)
Saved ./wheels/ansicolors-1.1.8-py2.py3-none-any.whl
ERROR: Exception:
Traceback (most recent call last):
  File "/home/jsirois/.local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 224, in _main
    status = self.run(options, args)
  File "/home/jsirois/.local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
    return func(self, options, args)
  File "/home/jsirois/.local/lib/python3.9/site-packages/pip/_internal/commands/download.py", line 138, in run
    preparer.save_linked_requirement(req)
  File "/home/jsirois/.local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 531, in save_linked_requirement
    assert req.link is not None
AssertionError
$ rm -rf wheels/ && pip download --dest wheels/ ansicolors==1.1.8 --constraint constraints.txt
Collecting ansicolors==1.1.8
  Using cached ansicolors-1.1.8-py2.py3-none-any.whl (13 kB)
Saved ./wheels/ansicolors-1.1.8-py2.py3-none-any.whl
Successfully downloaded ansicolors
@uranusjr
Copy link
Member

Did this ever work prior to 20.3? There is a reason we implemented a new resolver from scratch and try to remove the legacy resolver. This is one of the known issues with it that’s not reallly viable to handle. We are not going to fix issues in the legacy resolver for all the same reasons we implemented a new one.

@uranusjr uranusjr added the S: awaiting response Waiting for a response/more information label Dec 15, 2020
@jsirois
Copy link
Contributor Author

jsirois commented Dec 15, 2020

Yes, it has worked since day one of the introduction of the download command in 417f79d. A git bisect turns up b28e2c4 as the commit that introduced the bug. So this is a regression in the legacy-resolver introduced by work bringing the 2020-resolver to life.

@no-response no-response bot removed the S: awaiting response Waiting for a response/more information label Dec 15, 2020
@jsirois
Copy link
Contributor Author

jsirois commented Dec 15, 2020

I'll optimistically post a fix PR and link here in case you all are willing to accept it. If not, our project will just fork and apply the same PR in order to provide our users a smooth transition to migrate from the legacy-resolver to the 2020-resolver. As it stands, many of those users use --constraint and so otherwise cannot smoothly transition.

jsirois referenced this issue Dec 15, 2020
Previously, during dependency resolution for `pip download -d <dir>`
or `pip wheel -w <dir>`, distributions downloaded are always saved
to <dir>, even for those are only used in backtracking and are not
part of the returned requirement set.
@uranusjr
Copy link
Member

Given this and #9271, I feel we should revert the patch and discuss what download and wheel should do in the new resoler’s context.

jsirois added a commit to jsirois/pip that referenced this issue Dec 15, 2020
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
jsirois added a commit to jsirois/pip that referenced this issue Dec 15, 2020
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
jsirois added a commit to jsirois/pip that referenced this issue Dec 15, 2020
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
jsirois added a commit to pex-tool/pip that referenced this issue Dec 15, 2020
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
jsirois added a commit to jsirois/pex that referenced this issue Dec 15, 2020
This brings in a fix for `pip download --constraint` as well as support
for Python 3.10.

See: pypa/pip#9283
jsirois added a commit to pex-tool/pex that referenced this issue Dec 15, 2020
This brings in a fix for `pip download --constraint` as well as support
for Python 3.10.

See: pypa/pip#9283
jsirois added a commit to jsirois/pip that referenced this issue Jan 3, 2021
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
jsirois added a commit to jsirois/pip that referenced this issue Feb 1, 2021
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
@jsirois jsirois closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2023
cosmicexplorer pushed a commit to cosmicexplorer/pip that referenced this issue Aug 5, 2023
Download was not filtering out constraint-only requirements prior to
attempting to save them. Add a failing test under `--resolver=legacy`
and fix by adding in the filtering.

See: pypa@b28e2c4#r45135982

Fixes pypa#9283
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants