pypa/pip — pull request #604 by qwcode (2012-07-16 06:37:27+00:00)
Title: fix version sort in PackageFinder

When working on for tests for #598 (and possibly #571), I noticed when using -U and --find-links together, it would always re-install pkgs and never return "Requirement already up-to-date"

What I found to be the issue was the version sorting in PackageFinder.find_requirement. The sorting was only coincidentally accurate most of the time due to the order the various lists were put together.

There seemed to be an intention in the code to somehow be using the "Inf" object for sorting, but it wasn't actually using it, as best I could tell. In this change, I tried to change as little possible to fulfill the intention of using the Inf object. I did pull the sorting out into a specific method to make it easy to unit test.

Also, I discovered a condition, that would *never* evaluate to true. I added a FIXME comment.

*I am aware that tests are failing with this.*

This change seems to be exposing other cases where things were ok only by coincidence. I'll look at that tomorrow.

Posting this in incomplete form to possibly get feedback to make sure I'm not off the track with this change.