-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Make -U non-recursive by default, add --upgrade-recursive option #571
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
This would be fantastic. |
👍 |
I'd also consider |
@kennethreitz, I think |
Ah, good point. |
travisbot passing all the tests (and seeing that the commit from #fdintino didn't add or alter any tests) would imply that there was no previous coverage on this feature. tests/test_upgrade.py seems to be all about single distributions w/o dependencies. this would certainly be the time to add some tests related to recursion. |
I've forked fdintino's branch to add tests: ejucovy/pip@fdintino:fix-recursive-upgrades...ejucovy:fix-recursive-upgrades The first new test, The second new test passes in both cases. The third new test tests the new |
Nice catch, @qwcode. You're right, the implementation in this pull request breaks I've added an additional test for this behavior on my fork of fdintino's branch: ejucovy@e192a41 The last assertion in my new test fails on the branch. The same assertion passes on develop, so this feature isn't ready to be merged. |
Thanks for the unit tests! I was getting concerned by the lack of feedback. I'll be away from a computer until this evening (EDT) but I'll fix this when I get back home. Would the pip maintainers prefer if I merge commits where possible (having two commits, one from me and one from ejucovy) or does that not matter? I know that some projects prefer to have pull requests with as few commits as possible. Thanks. |
I added an def is_upgradeable(self, requirement):
if requirement.is_subrequirement and not requirement.is_extra:
return self.upgrade_recursive
else:
return self.upgrade
|
In case anyone is confused by the above travisbot messages, the first test failed because of a timeout on the travis server, so I force pushed with a different commit timestamp to initiate another travis build. |
Let me know if there's anything else I can do to help get this pulled in. |
@@ -1096,6 +1113,12 @@ def prepare_files(self, finder, force_root_egg_info=False, bundle=False): | |||
finally: | |||
logger.indent -= 2 | |||
|
|||
def is_upgradeable(self, requirement): | |||
if requirement.is_subrequirement and not requirement.is_extra: |
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.
Why are extras treated differently from other dependencies (always recursively upgraded)?
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.
At the time it made sense... I think my reasoning was that if you're supplying the extra alongside the package when issuing the upgrade command, then the expected behavior would be for the same upgrade logic to apply to both the base package and the extra packages, otherwise you wouldn't have used the extra specifier; e.g. why would you issue this command:
pip install -U jinja2[i18n]
and not this:
pip install -U jinja2
On the other hand, I'm not sure the extras make much sense in this context, so I'm not particularly attached to this line of reasoning and wouldn't be opposed to taking it out.
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.
Is there a verdict on this? Keep it or not?
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.
On further consideration, I think this is assuming too much. I'll take it out.
I integrated the above comments about the tests and |
@pnasrat , do you understand the scenario that leads to this kind of travis failure? |
I think it was because I force-pushed while it was starting to check it out, and the commit no longer existed for the merge. I had a typo in @ejucovy's author info |
btw, I was working on migrating tests last night for #598, and I'm pretty sure I found a bug that affects the current upgrade code pathway. I'll reconfirm and post a pull later this weekend, and reference this pull. you're working hard on this. I'll look it over in detail over the weekend. considering this is a compatibility breaking change, I think I might post something to the list requesting feedback. |
req_to_install.conflicts_with = req_to_install.satisfied_by | ||
req_to_install.satisfied_by = None | ||
else: | ||
install_needed = False | ||
if req_to_install.satisfied_by: | ||
if self.upgrade and not self.upgrade_recursive: |
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.
I don't follow this logic?
it seems like all we need to notify is this:
'Requirement already satisfied (use --upgrade to upgrade): %s' % req_to_install)
and if so, you don't need to pass in in upgrade
as a property of RequirementSet
, just upgrade_recursive
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.
I believe this message displays after any installation where the requirement is currently satisfied, not just upgrades. So if you performed
pip install Django
and you had Django 1.2.3 installed, you would see:
Requirement already satisfied (use --upgrade to upgrade): Django in [...]
whereas if Django was a dependency in install_requires that was satisfied but would be force-upgraded with --upgrade-recursive
, it would instead display:
Requirement already satisfied (use --upgrade-recursive to upgrade): Django>1.2 in [...]
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.
hmm, I take that message just as an FYI to the user about how to upgrade an individual package, that was satisfied during the current installation, not as a tip on how to redo the last installation command to get certain packages upgraded.
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.
That makes sense. I suppose the reason I did it this way is that with the previous behavior a pip install --upgrade
never presented this message, whereas now it can and it struck me as confusing that the user would be directed to perform a --upgrade
during a --upgrade
(the source of the confusion here being the ambiguity of the argument to pip install
)
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.
An upside of presenting the (use --upgrade-recursive to upgrade)
notice is that it might ease confusion for people expecting the previous pip install -U
behavior.
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.
yeah, I see your pt of view. maybe a 3rd person can help decide what is more intuitive in this case.
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.
it would be nice to see the tests confirm the exptected notifications
The pypy build failed on travis, but it doesn't look related to this commit. The message is a bit confusing, almost looks like a travis bug, but I'd need someone else to weigh in. |
pretty sure it's not related. I've seen that error pop up from time to time on other pypy tests. wish I knew how to guard against it once and for all. |
@pnasrat : any thoughts on this one? it's a merge candidate I think, but needs multiple maintainers giving it a go, since It changes the behavior of |
btw, I sent an email to the list months ago, asking if anyone had concerns with this change, and got no replies. |
I'd say lets hold off on behaviour changes until we manage to review the command rework. Then we should come give some thought to the user experience and the right commands and options to make that happen. Then that would go towards a 2.0 |
Just to make sure we're all on the same page, this isn't simply a reworking of the command, it fixes a long-standing bug with the behavior of recursive upgrades. The current behavior makes pip unworkable for certain workflows at The Atlantic, and judging from the ticket this is intended to fix we aren't alone in this regard. |
@fdintino , as for pip being "unworkable for certain workflows", I wrote up a gist a while back for your scenario. |
@qwcode: I hadn't seen that. It's counterintuitive, but that is helpful. As a rule, if we're using the unpatched pip, we always use I know you were just speculating, but to me #721 seems unrelated, since that seems to concern the apis in pip/commands/*, whereas this ticket is a modification to the behavior in pip/req.py. |
Updates? |
Specifically, I notice that #721 was closed, and this still passes the tests. |
@fdintino I appreciate your persistence on this. I think this pull is worthy, but it's going to need other maintainers giving it reviews and thumbs up, since it's a major change. |
@fdintino here's a thought. take your understanding you've gained from working on this, and use it towards a new usage:
|
@fdintino , fyi, I'm gonna work on "pip upgrade", and just try to get it done. |
Okay, I'd be willing to take a stab at it if you would like. |
ok, thanks, I'll see how my time goes. I'll include you for review on anything I do. |
and btw, if "pip upgrade --recursive" makes it in under my pull , I'll give you and ejucovy mucho credit. : ) |
hey, @fdintino, sorry, the reality of trying to get v1.3 tested and ready (and the latest effort to get ssl cert checking into pip) has stalled me on this. if you want to start on the I'm closing this in its current form, because I'm pretty keen on adding this via btw, see the new current cookbook entry on how to do a non-recursive install using what pip offers now: |
I believe that this pull request fixes #304. I incorporated a suggestion from one of the comments in that issue and kept the current behavior with the command option
--upgrade-recursive
.