-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
This 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
fooandsix, and print an error/warning telling the userbarnow has unsatisfied requirements. - Upgrade
barautomatically to 2.0.0. - Telling the user everything is up-to-date, since the installed
foo1.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).