6464from easybuild .tools .toolchain .toolchain import TOOLCHAIN_CAPABILITIES
6565from easybuild .tools .utilities import flatten , nub , quote_str
6666
67-
6867_log = fancylogger .getLogger ('easyconfig.tweak' , fname = False )
6968
70-
7169EASYCONFIG_TEMPLATE = "TEMPLATE"
7270
7371
@@ -277,6 +275,7 @@ def tweak_one(orig_ec, tweaked_ec, tweaks, targetdir=None):
277275
278276 class TcDict (dict ):
279277 """A special dict class that represents trivial toolchains properly."""
278+
280279 def __repr__ (self ):
281280 return "{'name': '%(name)s', 'version': '%(version)s'}" % self
282281
@@ -1142,8 +1141,8 @@ def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mappin
11421141 candidate_ver_list .append (r'%s\..*' % major_version )
11431142 candidate_ver_list .append (r'.*' ) # Include a major version search
11441143 potential_version_mappings = []
1145- highest_version = 0
1146- highest_version_ignoring_versionsuffix = 0
1144+ highest_version = None
1145+ highest_version_ignoring_versionsuffix = None
11471146
11481147 for candidate_ver in candidate_ver_list :
11491148
@@ -1189,10 +1188,10 @@ def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mappin
11891188 newversionsuffix = ''
11901189 if version :
11911190 if versionsuffix == newversionsuffix :
1192- if highest_version == 0 or LooseVersion (version ) > LooseVersion (highest_version ):
1191+ if highest_version is None or LooseVersion (version ) > LooseVersion (highest_version ):
11931192 highest_version = version
11941193 else :
1195- if highest_version_ignoring_versionsuffix == 0 or \
1194+ if highest_version_ignoring_versionsuffix is None or \
11961195 LooseVersion (version ) > LooseVersion (highest_version_ignoring_versionsuffix ):
11971196 highest_version_ignoring_versionsuffix = version
11981197 else :
@@ -1201,19 +1200,28 @@ def find_potential_version_mappings(dep, toolchain_mapping, versionsuffix_mappin
12011200 potential_version_mappings .append ({'path' : path , 'toolchain' : toolchain , 'version' : version ,
12021201 'versionsuffix' : newversionsuffix })
12031202
1204- if ignore_versionsuffix :
1205- if LooseVersion (highest_version_ignoring_versionsuffix ) > LooseVersion (highest_version ):
1203+ ignored_versionsuffix_greater = \
1204+ highest_version_ignoring_versionsuffix is not None and highest_version is not None and \
1205+ LooseVersion (highest_version_ignoring_versionsuffix ) > LooseVersion (highest_version )
1206+
1207+ exclude_alternate_versionsuffixes = False
1208+ if ignored_versionsuffix_greater :
1209+ if ignore_versionsuffix :
12061210 highest_version = highest_version_ignoring_versionsuffix
1207- else :
1208- if LooseVersion (highest_version_ignoring_versionsuffix ) > LooseVersion (highest_version ):
1211+ else :
12091212 print_warning (
12101213 "There may be newer version(s) of dep '%s' available with a different versionsuffix to '%s': %s" ,
12111214 dep ['name' ], versionsuffix , [d ['path' ] for d in potential_version_mappings if
12121215 d ['version' ] == highest_version_ignoring_versionsuffix ])
1213- # exclude candidates with a different versionsuffix
1216+ # exclude candidates with a different versionsuffix
1217+ exclude_alternate_versionsuffixes = True
1218+ else :
1219+ # If the other version suffixes are not greater, then just ignore them
1220+ exclude_alternate_versionsuffixes = True
1221+ if exclude_alternate_versionsuffixes :
12141222 potential_version_mappings = [d for d in potential_version_mappings if d ['versionsuffix' ] == versionsuffix ]
12151223
1216- if highest_versions_only and highest_version != 0 :
1224+ if highest_versions_only and highest_version is not None :
12171225 potential_version_mappings = [d for d in potential_version_mappings if d ['version' ] == highest_version ]
12181226
12191227 _log .debug ("Found potential version mappings for %s: %s" , dep , potential_version_mappings )
0 commit comments