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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move prepare_files logic to pip.resolve #4526
Conversation
Move out code (pip.req.req_set.prepare_files and support) out into pip.resolve
Use a method to prevent duplication across install and download
This likely means that even the tests would need to move around... That's for later though.
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 seems like a good direction but please, keep the PRs smalls (hopefully that's what you had in mind).
Ideally, one PR to refactor and an other PR to improve/change things.
pip/basecommand.py
Outdated
|
||
return Resolver( | ||
upgrade_strategy=strategy, | ||
finder=finder |
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.
nit: final ,
@xavfernandez That's exactly what I have in mind. In this PR, I am only going to move (a fair bit of) code and change only things that are needed to make it pass the tests. Once that is done, I'll make another PR actually making an improvement on the functionality or behaviour. The only exception in this PR to this rule, right now, is |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Well, as long as you set the strategy to |
That's how it is. :) |
Umm... I can't find what's causing these tests to fail. I'm pretty sure it's some line I messed up while updating for the change in location but I can not seem to pin point it. @dstufft @xavfernandez @pfmoore Could one of you please look into this? PS: Starting today, I'll be afk for around a week. :/ Sorry. |
pip/resolve.py
Outdated
req_to_install.check_if_exists() | ||
if req_to_install.satisfied_by: | ||
should_modify = ( | ||
self.upgrade_strategy == "not-allowed" and |
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 should be an or!!!
9a35c34
to
2bd5714
Compare
Hopefully, this is all that needs fixing.
/request-review @dstufft @xavfernandez @pfmoore |
@@ -196,7 +196,8 @@ def run(self, options, args): | |||
None | |||
) | |||
|
|||
requirement_set.prepare_files(finder) | |||
resolver = self._build_resolver(options, finder) | |||
resolver.resolve(requirement_set) |
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 appears like the way this is working is to mutate the RequirementSet
that we're passing in. That is OK for this PR since that more closely resembles the existing code (and thus reduces the amount of code churn), but thinking forward I think it would be great if we can get this code refactored so we're passing in the things we want to install, and then it returns a new thing that lists everything we need to install. These could both be RequirementSets
s possibly?
Anyways, not an immediate concern, just something to keep in mind.
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.
These could both be
RequirementSet
s possibly?
Is exactly what I'm thinking.
pip/req/req_set.py
Outdated
not self.requirements[name].constraint or | ||
name in self.requirement_aliases and | ||
not self.requirements[self.requirement_aliases[name]].constraint | ||
) |
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 looks like it was just reformatting? If so can we just revert this back to the existing code. A separate PR could clean this up, but atm I think it's just adding noise to an already large diff.
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.
Roger that!
Did we just not have any tests for this functionality before? Or was it all tested indirectly by calling commands that used |
It seems to me that it's the latter. A whole bunch of tests broke when I made a change that changed the behavior from that of prepare_files. |
Ok good, at least we have some validation that the this isn't breaking things! At some level it's more or less impossible to actually do a meaningful code review on a large copy/paste job like this. Given the tests were not (really) modified I'm inclined to believe the copy/paste was done OK and once the minor nits I pointed out get addressed I'm happy to merge this. |
This is the first of my GSoC 2017 PRs! 馃帀
This PR moves out all the logic in
pip.req.req_set.RequirementSet.prepare_files
into a newpip.resolve
module. The idea is that all the things that are to be done while determining which packages (and versions) should be installed would happen in this new module.I'm making this PR so that I can have tests run on the Travis CI - which happens to be faster than on my laptop and also frees my laptop up so that I can continue working. :)
TODO:
Move parts of(will do in next PR)RequirementSet.__init__
topip.resolve.Resolver
PS: This feels a lot like taking the heart out of a beast. XD