Fix and improve handling of extras while resolving dependencies #2887
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: #2545
Resolves: #2494
Resolves: #2300
Resolves: #2080
Resolves: #1609
Resolves: #1616
This one was bothering for a while and was quite the struggle to fix.
Basically, extras could trip up Poetry if the package already existed in the dependency graph leading to dependencies being ignore or uninstalled when updating dependencies.
To make it work, a rather big refactoring was required (see python-poetry/poetry-core#78) to make dependencies and packages comparison more accurate.
The main trick here is that a package with extras will now have its non-extra version as a dependency to help the resolver figure out what needs to be done.
Overall, it simplifies the code by always adding all dependencies of packages (even optional ones) and it's the
Provider
that will now decide which ones should be exposed to the resolver based on the extras selected.One last thing of note is that source urls of file and directory dependencies will now be the fully resolved path, i.e. absolute, to actually be able to make comparisons.