@@ -101,6 +101,7 @@ def sort_path(path):
101
101
return files , urls
102
102
103
103
def find_requirement (self , req , upgrade ):
104
+
104
105
def mkurl_pypi_url (url ):
105
106
loc = posixpath .join (url , url_name )
106
107
# For maximum compatibility with easy_install, ensure the path
@@ -165,21 +166,23 @@ def mkurl_pypi_url(url):
165
166
if not found_versions and not page_versions and not dependency_versions and not file_versions :
166
167
logger .fatal ('Could not find any downloads that satisfy the requirement %s' % req )
167
168
raise DistributionNotFound ('No distributions at all found for %s' % req )
169
+ installed_version = []
168
170
if req .satisfied_by is not None :
169
- found_versions . append (( req .satisfied_by .parsed_version , InfLink , req .satisfied_by .version ))
171
+ installed_version = [( req .satisfied_by .parsed_version , InfLink , req .satisfied_by .version )]
170
172
if file_versions :
171
173
file_versions .sort (reverse = True )
172
174
logger .info ('Local files found: %s' % ', ' .join ([url_to_path (link .url ) for parsed , link , version in file_versions ]))
173
- found_versions = file_versions + found_versions
174
- all_versions = found_versions + page_versions + dependency_versions
175
+ #this is an intentional priority ordering
176
+ all_versions = installed_version + file_versions + found_versions + page_versions + dependency_versions
175
177
applicable_versions = []
176
178
for (parsed_version , link , version ) in all_versions :
177
179
if version not in req .req :
178
180
logger .info ("Ignoring link %s, version %s doesn't match %s"
179
181
% (link , version , ',' .join (['' .join (s ) for s in req .req .specs ])))
180
182
continue
181
183
applicable_versions .append ((parsed_version , link , version ))
182
- applicable_versions = sorted (applicable_versions , reverse = True )
184
+ #bring the latest version to the front, but maintains the priority ordering as secondary
185
+ applicable_versions = sorted (applicable_versions , key = lambda v : v [0 ], reverse = True )
183
186
existing_applicable = bool ([link for parsed_version , link , version in applicable_versions if link is InfLink ])
184
187
if not upgrade and existing_applicable :
185
188
if applicable_versions [0 ][1 ] is InfLink :
@@ -191,7 +194,7 @@ def mkurl_pypi_url(url):
191
194
return None
192
195
if not applicable_versions :
193
196
logger .fatal ('Could not find a version that satisfies the requirement %s (from versions: %s)'
194
- % (req , ', ' .join ([version for parsed_version , link , version in found_versions ])))
197
+ % (req , ', ' .join ([version for parsed_version , link , version in all_versions ])))
195
198
raise DistributionNotFound ('No distributions matching the version for %s' % req )
196
199
if applicable_versions [0 ][1 ] is InfLink :
197
200
# We have an existing version, and its the best version
@@ -675,7 +678,7 @@ def show_url(self):
675
678
return posixpath .basename (self .url .split ('#' , 1 )[0 ].split ('?' , 1 )[0 ])
676
679
677
680
#An "Infinite Link" that compares greater than other links
678
- InfLink = Link (Inf )
681
+ InfLink = Link (Inf ) #this object is not currently used as a sortable
679
682
680
683
681
684
def get_requirement_from_url (url ):
0 commit comments