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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop INSTALLED_VERSION #3211

Merged
merged 3 commits into from
Nov 5, 2015

Conversation

xavfernandez
Copy link
Member

closes #703

This refactor is a first step to ease the transition to a simpler Finder, only returning a list of InstallationCandidate (or alternatively only the best/None) from a req_name and a version specifier (i.e. something like django>=1.5,<1.7).

The logic of satisfied_by/upgrade could/should be performed in an other place.

Review on Reviewable

@xavfernandez xavfernandez force-pushed the drop_installed_version branch from 07b790b to cebbd14 Compare October 28, 2015 00:01
@xavfernandez
Copy link
Member Author

cc @qwcode since you created #703

@rbtcollins
Copy link

I'm not quite sure what this is doing...

The stopping of sorting by location is dubious - I thnk #928 should be closed won'tfix - a fundamental assumptio n is that two distributions of X with version Y are equivalent.

@qwcode
Copy link
Contributor

qwcode commented Nov 4, 2015

@xavfernandez I can look at this more tomorrow, but to be clear, I wasn't imagining this much refactor when I wrote #703 3 years ago. At the time, I think I was just thinking that INSTALLED_VERSION didn't need to be based on the inf object since we weren't using the sorting features of inf. So, I think you should explain the refactor more than dubbing it as simply a close for #703.

Also, I don't think you should throw a #928 change into this. that's a behavior change that should be considered separately in another PR IMO.

@xavfernandez
Copy link
Member Author

The stopping of sorting by location is dubious - I thnk #928 should be closed won'tfix - a fundamental assumptio n is that two distributions of X with version Y are equivalent.

Well I don't see a good reason to prefer http://zzz.org/foo-1.0.tar.gz to http://aaa.pypi.org/foo-1.0.tar.gz. The sorting by location seems dubious to me and only serves one purpose: making sure the INSTALLED_VERSION we added ourself comes first.
I don't think we should commit to always respect the find-links order (as stated in #928) but since pip 8 could provide it with less work (i.e. no sorting), why not provide it ?

Edited: but you're right #928 is dubious and was closed. The last commit does not reference it anymore.

@xavfernandez xavfernandez force-pushed the drop_installed_version branch from b01a7c7 to e27616f Compare November 4, 2015 09:12
@xavfernandez
Copy link
Member Author

@qwcode the refactor aims at extracting the logic of what to do with the installed version (req.satisfied_by) and upgrade outside of the InstallationCandidate sorting.

The behavior before/after the refactor does not change:

satisfied applicable_versions upgrade expected result
y y y return applicable_versions[0] or raise BestInstalled
y y n log, satisfied and info on latest (up-to-date or not), return None
y n y log it is the up-to-date, raise BestInstalled
y n n log it is the up-to-date, return None
n y y log list and best, return applicable_versions[0]
n y n log list and best, return applicable_versions[0]
n n y raise DistributionNotFound
n n n raise DistributionNotFound

It just does not rely anymore on the sort by location.

@xavfernandez
Copy link
Member Author

From my point of view, ideally, the finder should only be provided with a requirement 'django>=1.5,<1.7' (a req_name and a version specifier) and only return a list of InstallationCandidate (or alternatively only the best/None).

The logic of satisfied_by/upgrade should be performed in an other place.

@dstufft
Copy link
Member

dstufft commented Nov 4, 2015

I agree with the idea that finder should only be provided with a requirement and return a list of candidates (or the best candidate).

@xavfernandez
Copy link
Member Author

I agree with the idea that finder should only be provided with a requirement and return a list of candidates (or the best candidate).

I'd say this PR is a refactoring cleanup to make this next change easier.

@qwcode
Copy link
Contributor

qwcode commented Nov 4, 2015

  1. Again, let's break this PR up into 2 PRs (the refactor and the sorting change). If a PR depends on another, then explain that in the description. If someone comes back to this 6 months later, it will be much clearer. Also, it's clearer for the current participants. For example, Donald is giving a +1 to your motivation for making the refactor, but it's not clear if he's supporting the sorting behavior change. It's unnecessary confusion.

  2. Correct me if I'm wrong, but your point that sorting by location is how we keep INSTALLED_VERSION first is wrong I think. We put it in front using direct insertion and when it is sorted, it's based on a custom key that doesn't use location. If I'm wrong, show me exactly where that happens. btw, the find_links location sorting happens in this line: file_versions.sort(reverse=True), not in applicable_versions = self._sort_versions(applicable_versions)

  3. I'm fine with the motivation to simplify the finder to "only return a list [...]" (to be clear, that change isn't in here, but you're wanting that later. that's the kind of remark that would be great in the description for the refactor PR)

  4. I agree that the sorting by location is odd, but it's a fact at the moment, so we have to consider the ramifications of people possibly depending on it. It's at least changelog worthy (and again better for the change to be isolated in it's own PR if we're going to reference it in the changelog)

  5. If we pull out the location sorting, then I'm thinking that we need to ensure some repeatable order, and have a test that we maintain that.

@dstufft
Copy link
Member

dstufft commented Nov 4, 2015

Donald is giving a +1 to your motivation for making the refactor, but it's not clear if he's supporting the sorting behavior change

I haven't read the code at all so my +1 is only to the idea of refactoring the finders to only find things and move the selection logic elsewhere.

If we pull out the location sorting, then I'm thinking that we need to ensure some repeatable order, and have a test that we maintain that.

Agreed, two invocations of pip should always return the same thing from a finder.

@xavfernandez xavfernandez force-pushed the drop_installed_version branch from e27616f to 4782ffe Compare November 4, 2015 21:53
@xavfernandez
Copy link
Member Author

  1. Correct me if I'm wrong, but your point that sorting by location is how we keep INSTALLED_VERSION first is wrong I think. We put it in front using direct insertion and when it is sorted, it's based on a custom key that doesn't use location. If I'm wrong, show me exactly where that happens. btw, the find_links location sorting happens in this line: file_versions.sort(reverse=True), not in applicable_versions = self._sort_versions(applicable_versions)

@qwcode you're right :) I missed that, 1acff7ed10912a2 was removed from the PR.

  1. I'm fine with the motivation to simplify the finder to "only return a list [...]" (to be clear, that change isn't in here, but you're wanting that later. that's the kind of remark that would be great in the description for the refactor PR)

Good point, I updated it.

Good thing I waited before merging 😀

@qwcode
Copy link
Contributor

qwcode commented Nov 4, 2015

ok, cool, it's just a refactor now. looks ok to me.

:shipit:

xavfernandez added a commit that referenced this pull request Nov 5, 2015
Drop INSTALLED_VERSION and light refactor of Finder.find_requirement
@xavfernandez xavfernandez merged commit 0c625b7 into pypa:develop Nov 5, 2015
@xavfernandez
Copy link
Member Author

Thanks :)

@xavfernandez xavfernandez deleted the drop_installed_version branch November 5, 2015 08:38
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants