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 and improve handling of extras while resolving dependencies #2887

Merged
merged 1 commit into from Sep 18, 2020

Conversation

sdispater
Copy link
Member

@sdispater sdispater commented Sep 6, 2020

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.

  • Added tests for changed code.
  • Updated documentation for changed code.

@sdispater sdispater added the area/solver Related to the dependency resolver label Sep 6, 2020
@sdispater sdispater force-pushed the fix-transitive-extras branch 10 times, most recently from f9cafca to c08e155 Compare Sep 7, 2020
@sdispater sdispater marked this pull request as ready for review Sep 8, 2020
@sdispater sdispater requested a review from a team Sep 8, 2020
@sdispater sdispater force-pushed the fix-transitive-extras branch 4 times, most recently from 9ad2e5d to d38c901 Compare Sep 16, 2020
Copy link
Member

@abn abn left a comment

Looking good. Some minor fixes.

poetry/console/commands/show.py Show resolved Hide resolved
poetry/factory.py Outdated Show resolved Hide resolved
poetry/packages/locker.py Outdated Show resolved Hide resolved
poetry/packages/locker.py Outdated Show resolved Hide resolved
poetry/packages/locker.py Outdated Show resolved Hide resolved
tests/utils/test_extras.py Outdated Show resolved Hide resolved
tests/mixology/helpers.py Outdated Show resolved Hide resolved
poetry/version/version_selector.py Outdated Show resolved Hide resolved
poetry/console/commands/debug/resolve.py Outdated Show resolved Hide resolved
poetry/console/commands/debug/resolve.py Outdated Show resolved Hide resolved
@sdispater sdispater force-pushed the fix-transitive-extras branch 3 times, most recently from 2639c45 to c94d2a6 Compare Sep 18, 2020
abn
abn previously approved these changes Sep 18, 2020
abn
abn approved these changes Sep 18, 2020
@sdispater sdispater merged commit 5acf8fa into master Sep 18, 2020
@sdispater sdispater deleted the fix-transitive-extras branch Sep 18, 2020
@sdispater sdispater mentioned this pull request Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment