Skip to content
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

Merged
merged 23 commits into from Jun 13, 2017
Merged

Conversation

pradyunsg
Copy link
Member

@pradyunsg pradyunsg commented May 31, 2017

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 new pip.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 the code
  • Get the tests passing
  • Move parts of RequirementSet.__init__ to pip.resolve.Resolver (will do in next PR)

PS: This feels a lot like taking the heart out of a beast. XD

Copy link
Member

@xavfernandez xavfernandez left a 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.


return Resolver(
upgrade_strategy=strategy,
finder=finder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: final ,

@pradyunsg
Copy link
Member Author

@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 upgrade_strategy handling. Should I make those changes - special handling and moving attributes of RequirementSet - in the next PR, not this one?

@pypa-bot
Copy link

pypa-bot commented Jun 1, 2017

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 master branch into this pull request or rebase this pull request against master then it will eligible for code review and hopefully merging!

@pypa-bot pypa-bot added the needs rebase or merge PR has conflicts with current master label Jun 1, 2017
@xavfernandez
Copy link
Member

The only exception in this PR to this rule, right now, is upgrade_strategy handling. Should I make those changes - special handling and moving attributes of RequirementSet - in the next PR, not this one?

Well, as long as you set the strategy to not-allowed for download and wheel commands I think it can stay in this PR.

@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Jun 1, 2017
@pradyunsg
Copy link
Member Author

Well, as long as you set the strategy to not-allowed for download and wheel commands I think it can stay in this PR.

That's how it is. :)

@pradyunsg
Copy link
Member Author

pradyunsg commented Jun 6, 2017

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
Copy link
Member Author

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!!!

Hopefully, this is all that needs fixing.
@pradyunsg pradyunsg changed the title [WIP] Move prepare_files logic to pip.resolve Move prepare_files logic to pip.resolve Jun 13, 2017
@pradyunsg
Copy link
Member Author

/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)
Copy link
Member

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 RequirementSetss possibly?

Anyways, not an immediate concern, just something to keep in mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could both be RequirementSets possibly?

Is exactly what I'm thinking.

not self.requirements[name].constraint or
name in self.requirement_aliases and
not self.requirements[self.requirement_aliases[name]].constraint
)
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger that!

@dstufft
Copy link
Member

dstufft commented Jun 13, 2017

Did we just not have any tests for this functionality before? Or was it all tested indirectly by calling commands that used prepare_files?

@pradyunsg
Copy link
Member Author

Did we just not have any tests for this functionality before? Or was it all tested indirectly by calling commands that used prepare_files?

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.

@dstufft
Copy link
Member

dstufft commented Jun 13, 2017

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.

@dstufft dstufft merged commit f555802 into pypa:master Jun 13, 2017
@pradyunsg pradyunsg deleted the refactor/resolve branch June 13, 2017 18:42
@pradyunsg pradyunsg added the type: refactor Refactoring code label Oct 25, 2017
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: refactor Refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants