group packages correctly when exporting #5154
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Check List
Resolves: #issue-number-here
The attempt to
groupby
during exports can be foiled by cases where a dependency is present with more than one version: eg if we see[foo 1, foo 2, foo 1]
then we end up with three groups rather than two.This improves #5141, in particular the lines for click that we now get for the example given there are
which looks acceptable.
However, in the effort to simplify this to a testcase I ran into at least two bugs that I don't know how to fix, and these are exhibited by the testcase...
Bug 1
Here's what we get for
click
:two of the 7.1.2 possibilities overlap the 8.0.3 marker, which is not OK.
The cause seems to be that when the export code comes to process the "top-level" entries for click-didyoumean and click-plugins it sees that these should be installed for a broad range of python versions, and decides that therefore so should their dependency click.
As best I can see the fundamental problem is that the lock file does not record which packages are actually top-level dependencies, and which are not. I don't see how to fix this without recording the actual top-level requirements as taken from
pyproject.toml
, which would allow the export code to reach click-didyoumean and click-plugins only in a path where it is taking account of parent markers.Bug 2
The output markers for click-plugins and click-didyoumean (sort of) are also faulty in the test.
The new problem here is that the marker setter at https://github.com/python-poetry/poetry-core/blob/0113a5a172e57424dbf5b2031d8c77097c725b5e/src/poetry/core/packages/dependency.py#L161 does not update the python versions correctly:
python_versions
in the Any marker, and therefore does not clear "python < 3.7" from the_python_versions