-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Change install command's default behaviour to upgrade packages by default #3806
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
Conversation
I see some failures in the tests due to HTTP 403s in the test-run. I think this is due to the recent change on PyPI to redirecting If such is the case, could someone trigger a Travis CI re-run1 of the tests on master to see if it is still in good shape? If not, that would have to be fixed. 1 there's a button or something for that in their web-UI (edited) |
084adf2
to
e4caa6b
Compare
This commit changes pip install's default behavior to upgrade directly mentioned packages and not reinstall dependecies if they are already installed and meet the minimum requirements.
pip install changed behaviour to upgrade by default. install --target will now also behave similarly, replacing directories unless told to do otherwise via a flag. The behaviour change makes --upgrade option a no-op. This commit also adds a new --no-replace flag that does not allow replacement of existing files/folders with --target and does not reinstall packages when used without --target. [skip ci] because the tests aren't updated for this change.
This reverts commit 998b6fde3740873952c8873e31f2285dba19008f.
Remove the ability to replace existing files and folders with install --target to truly remove the need for --upgrade. [skip ci] because tests aren't ready yet.
Correct existing tests according to the new behaviour Add new tests for previously non-existent behaviour
Rebased work off fixed master. |
e4caa6b
to
ce21547
Compare
The tests added for non-eager upgrading checks were passing but they were not checking if things got installed. Upon addition of these checks, the tests started failing sincethey were not using the data/packages directory. This patch fixes the tests to run pip with correct arguments and check for the right things.
/cc @njsmith @xavfernandez @dstufft @pfmoore This PR now implements a proposal based on what was discussed earlier over at #3786. Any further discussions may please be done here. There also a new (read updated) write-up regarding the same, which I intend to link to when I announce this change on distutils-sig; still undecided on announcing on python-list. I request someone to review the PR and the write-up. Let me know what you think! 😄 |
This has mostly been done already, linking them to #59. |
The new write-up looks good. I'll try to get some time to review the PR, but can't promise anything, as real life is busy at the moment. |
"Only if needed" Recursive Upgrade | ||
********************************** | ||
Upgrade Behaviour | ||
***************** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section could possibly be deleted, since it only existed to give folks a workaround for the old confusing behavior, and after this pr is merged then pip will join most other package managers in not even having a concept of a "eager upgrade". We don't need to emphasize to people that it doesn't have eager upgrade, any more than we need to emphasize that it doesn't have four-wheel drive or email reading capabilities.
Alternatively, since people will often consult the latest manual even for old versions, and I think there are pages out there that link to this section, it might make sense to keep the old information and section title (since the section title determines the link anchor) but reframed as: "it used to be that pip did a weird thing with upgrades, and this section was here to tell you how to work around it. Starting with version X, it doesn't anymore. So the recommended way to work around it is to upgrade to version X or better. As a historical note, the way you used to work around this was by running pip ...
."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping this as a historical note makes sense sounds good to me.
In addition to my line comments above:
I think that's everything -- overall it looks pretty good to me (though it would probably be good to get a quick pass over the core logic by someone who is more familiar with pip's core requirement logic). And thanks so much for pushing this forward! |
@pypa/pip-committers: BTW, in case it's any incentive ;-), I'm giving a talk at SciPy on July 15 about new stuff in pip/wheels/pypi/etc. I would be very happy to use that as a soapbox to tell people that this has been fixed so they should start putting correct dependency metadata into their packages -- but that only works if this is merged (or even better, released!) by then. |
On it.
I think if the version number of the passed item is same or newer, it would result in a reinstall. If it's older, no change takes place... I need to verify if it is indeed the case though.
I would like to have it to be discussed/debated and explicitly decided before we |
You're welcome! 😄 |
The section that commented on the upgrade behaviour now metions the original purpose of the adding the section and adds a historic note.
@njsmith is correct. As it stands, this PR means pip does cause a reinstall on editted in: I don't think I want to cause this PR to change the behaviour.
I had assumed that it would not have caused a reinstall of an older version over an existing version. Thanks for spotting this. I didn't notice that this was a consequence of the changes I made. (editted) |
But |
Incorrect. Should I add some guard code to stop doing this and defer it to #536?
|
Hmm, is that the agreed behaviour? I'm not particularly happy that a simple I would have expected to need Specifically, I don't think that installing something with an explicit version number in the filename (i.e., a wheel or sdist) should reinstall or downgrade without needing a I just checked, and yes, |
@pfmoore: I definitely think we should consider this PR as written as making two changes: the intentional change to make The first change was extensively discussed in #3786 and friends, and I think we're all ok with it. By an interesting coincidence, the second change actually is also one that has been proposed and discussed in #536. You can read the issue for the details, but the basic argument there was that if I tell pip that I want this file right here to be installed, then the only way pip can make that happen is by installing that file. This is somewhat similar to if I say From my read of the #536 history, it looks like @dstufft, @xavfernandez, @rbtcollins, @njsmith, @ChrisBarker-NOAA, @rgommers were in favor of this change, @piotr-dobrogost against it, and @pfmoore hadn't made up his mind yet ;-). So for this PR, options are:
As a general rule I am a fan of splitting up PRs, but in this case I'm not so sure. There does seem to be widespread consensus in favor of both of the changes here, and "splitting it up" is not so easy, because the two behaviors are already coupled in the current code base. Basically we'd have to ask @pradyunsg to muck around in the internals more to explicitly disable the location handling behavior... and then I guess we'd have another PR immediately afterwards just to remove that work again? Seems like a lot of work for not much benefit. So my preference would be to go ahead and merge this, closing both #3786 and #536 in one super efficient click :-). OTOH if everyone wants to restart the argument about #536 again, then (a) do you really have to? :-(, (b) if you do then fine, but then we should probably add those hacks to this PR because we don't want it to get stalled out again (the bug's been open what, 4 years now?) |
Thanks for the tag. I'm pro #536; I'm not at all pro the proposed changes in #3786. The idea of pip install X upgrading X implicitly and dependencies only as required I'm fine with - is that what this does? The mucking around with other command line options like the meaning of -U is what concerns me. If this does that, I think it would be a mistake to merge it. |
Nope, thanks for the back-reference (there's been so much debate on this issue, that I've forgotten most of the history). I'm happy to defer to the majority. |
So, is this accidental change agreed upon and I maybe add a few more tests for it? If not, I'll be fine with going and diving into the internals and try to see what I can do to revert it, as much as I'll prefer not to. Heads Up: I have to move to another city by 1st July. After that, I don't know whether I'll have the free time for this PR. |
I forgot to push the commits adding @njsmith's suggestions. 😅 |
@pradyunsg: It sounds like (tentatively) everyone is fine with the "accidental change". It certainly needs to have a test -- but I think it might already? And it should be mentioned as in the release notes as a separate item from the install-now-upgrades change. |
I doubt it has a test. The change broke only one test which I modified to pass... |
I've just pushed 4 new tests for the behaviour change related to #536. Could someone check that this is indeed the required behaviour? I'll prefer to defer updating the changelog to someone else. It's got a section for 8.2.0 but I would like to see this in 9.0.0. I'll wait for the go ahead from @njsmith and @pfmoore before announcing on the distutils-sig and python-list. |
One extra newline. One extra newline broke the build. :/ |
I'm OK with you announcing it. It seems good enough to me. Holding off for perfection on the PR is not going to help (particularly if your free time is due to drop significantly soon!) |
Great! I just sent the mail. 😁 |
I have now realized how powerful newlines are. :P
Fixed the build. |
Hmm, is this still relevant after the merge of #3972 ? |
I think this can be closed. If someone feels it's still relevant, we can reopen this. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Resolves #3786.
Resolves #536.
Check-list:
--target
problemThis change is