Warn users about dependency conflicts when updating other packages
See original GitHub issueThis is a mental note on a topic I realise needing a discussion while working on another issue.
Say we have package foo
and bar
with the following dependencies:
foo 1.0.0
six<1.12
foo 2.0.0
six>=1.12
bar 1.0.0
six<1.12
bar 2.0.0
six>=1.12
Given an environment with the followings installed:
foo 1.0.0
bar 1.0.0
six 1.11.0
and the user runs pip install --upgrade foo
. What should we do? If we upgrade foo
to 2.0.0, six
needs to be upgraded as well (as an intrinsic requirement), but now it would conflict with bar
. I can think of three possibile approaches:
- Upgrade
foo
andsix
, and print an error/warning telling the userbar
now has unsatisfied requirements. - Upgrade
bar
automatically to 2.0.0. - Telling the user everything is up-to-date, since the installed
foo
1.0.0 is the latest version without conflicts. - Error out without modifying the environment, saying the upgrade would introduce incompatibilities.
Approach 1 is the simplest, but might be too difficult for the user to notice (especially on CI). This is probably not a good idea if we can avoid it.
Approach 2 looks like a good idea at first glance, but IMO may be confusing to the user. The dependency graph would be much less complex in more than one way in practice, and it would be difficult for the user to notice, or understand why a seemingly unrelated package got upgraded.
Approach 3 is “correct” in thoery, but is as unuseful to the user as pip’s famous “No matching distributions found for” error. There is clearly a newer version to upgrade to from the user’s perspective. Why is pip not finding it? Open GitHub and file a bug report.
Approach 4 is the most reasonable to me. In the above example, pip would emit something like six>=1.12 (required by foo) would cause incompatibility in bar (requires six<1.12)
. The downside is pip would need to do more work to interpret the resolution result (this does not fit into the resolution process IMO).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:61 (55 by maintainers)
Top GitHub Comments
What is the practical solution to https://github.com/pypa/pip/issues/9482 though? If I’m running
pip3 install -U foo
, then really I want it stop and warn me before upgrading if the upgrade would break a dependency. Only if I pass an--ignore-breakages
option or something would I want it to go ahead. This is highly undesirable behaviour at present.My apologies for giving an alternative that is wrong on all accounts. I hope thought that my confusion might help to show how the original message might be misinterpreted. Let me try a few more:
If these don’t work hopefully my failure to find a better message does not mean that no one else will try to find one.