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

improve applicable_versions = sorted... #138

Closed
vbabiy opened this Issue Mar 15, 2011 · 5 comments

Comments

Projects
None yet
1 participant
@vbabiy
Contributor

vbabiy commented Mar 15, 2011

I've hacked this in order to run pip in python3 which doesn't support cmp= in sorted

--- index.py~   2010-02-12 04:45:07.134856937 +0100
+++ index.py    2010-02-12 05:00:04.718850220 +0100
@@ -129,8 +129,8 @@
                             % (link, version, ','.join([''.join(s) for s in req.req.specs])))
                 continue
             applicable_versions.append((link, version))
-        applicable_versions = sorted(applicable_versions, key=operator.itemgetter(1),
-            cmp=lambda x, y : cmp(pkg_resources.parse_version(y), pkg_resources.parse_version(x))
+        applicable_versions = sorted(applicable_versions,
+                key=lambda v: pkg_resources.parse_version(v[1])
         )
         existing_applicable = bool([link for link, version in applicable_versions if link is Inf])
         if not upgrade and existing_applicable:

@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 15, 2011

Contributor
  • Changed status from new to open.

Original Comment By: Jannis Leidel
Contributor

vbabiy commented Mar 15, 2011

  • Changed status from new to open.

Original Comment By: Jannis Leidel
@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 15, 2011

Contributor

avoid sorted(cmp=...) for Python 3; thanks gdamjan! fixes #62

→ [Author: Carl Meyer

Age: 13 months ago

avoid sorted(cmp=...) for Python 3; thanks gdamjan! fixes
62">r415:5e5ddddc74c6]2


Original Comment By: Carl Meyer
Contributor

vbabiy commented Mar 15, 2011

avoid sorted(cmp=...) for Python 3; thanks gdamjan! fixes #62

→ [Author: Carl Meyer

Age: 13 months ago

avoid sorted(cmp=...) for Python 3; thanks gdamjan! fixes
62">r415:5e5ddddc74c6]2


Original Comment By: Carl Meyer
@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 15, 2011

Contributor

The pip logic actually requires a reverse=True parameter to sorted(..)


Original Comment By: gdamjan
Contributor

vbabiy commented Mar 15, 2011

The pip logic actually requires a reverse=True parameter to sorted(..)


Original Comment By: gdamjan
@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 15, 2011

Contributor

Added the reverse, thanks.

So I thought the tests all passed with the previous commit, but was fooled by
the fact that apparently now that pip's a module, if you run the pip tests
from in a virtualenv with pip installed (which, nowadays, is any virtualenv),
it tests that installed pip, not the checkout you're running the tests in.
Which is useless. Good to know for future...


Original Comment By: Carl Meyer
Contributor

vbabiy commented Mar 15, 2011

Added the reverse, thanks.

So I thought the tests all passed with the previous commit, but was fooled by
the fact that apparently now that pip's a module, if you run the pip tests
from in a virtualenv with pip installed (which, nowadays, is any virtualenv),
it tests that installed pip, not the checkout you're running the tests in.
Which is useless. Good to know for future...


Original Comment By: Carl Meyer
@vbabiy

This comment has been minimized.

Show comment
Hide comment
@vbabiy

vbabiy Mar 15, 2011

Contributor

I've found the same thing in req.py

[1][1]

[2][2]

[3][3]

[4][4]

[5][5]

[6][6]

[7][7]

[8][8]

[9][9]



@@ -1412,7 +1412,7 @@

         /a/path/to/a/file.txt are both in the set, leave only the

         shorter path."""

         short_paths = set()

-        for path in sorted(paths, lambda x, y: cmp(len(x), len(y))):

+        for path in sorted(paths, key=len):

             if not any([(path.startswith(shortpath) and

                          path[len(shortpath.rstrip(os.path.sep))] ==

os.path.sep)

                         for shortpath in short_paths]):

Original Comment By: gdamjan
Contributor

vbabiy commented Mar 15, 2011

I've found the same thing in req.py

[1][1]

[2][2]

[3][3]

[4][4]

[5][5]

[6][6]

[7][7]

[8][8]

[9][9]



@@ -1412,7 +1412,7 @@

         /a/path/to/a/file.txt are both in the set, leave only the

         shorter path."""

         short_paths = set()

-        for path in sorted(paths, lambda x, y: cmp(len(x), len(y))):

+        for path in sorted(paths, key=len):

             if not any([(path.startswith(shortpath) and

                          path[len(shortpath.rstrip(os.path.sep))] ==

os.path.sep)

                         for shortpath in short_paths]):

Original Comment By: gdamjan

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment