Use key sorting instead of cmp()
- Get rid of pkgsort() usage for preferred variants. - Concretization is now entirely based on key-based sorting. - Remove PreferredPackages class and various spec cmp() methods. - Replace with PackagePrefs class that implements a key function for sorting according to packages.yaml. - Clear package pref caches on config test. - Explicit compare methods instead of total_ordering in Version. - Our total_ordering backport wasn't making Python 3 happy for some reason. - Python 3's functools.total_ordering and spelling the operators out fixes the problem. - Fix unicode issues with spec hashes, json, & YAML - Try to use str everywhere and avoid unicode objects in python 2.
This commit is contained in:
		
							
								
								
									
										17
									
								
								lib/spack/external/functools_backport.py
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								lib/spack/external/functools_backport.py
									
									
									
									
										vendored
									
									
								
							@@ -28,3 +28,20 @@ def total_ordering(cls):
 | 
			
		||||
            opfunc.__doc__ = getattr(int, opname).__doc__
 | 
			
		||||
            setattr(cls, opname, opfunc)
 | 
			
		||||
    return cls
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@total_ordering
 | 
			
		||||
class reverse_order(object):
 | 
			
		||||
    """Helper for creating key functions.
 | 
			
		||||
 | 
			
		||||
       This is a wrapper that inverts the sense of the natural
 | 
			
		||||
       comparisons on the object.
 | 
			
		||||
    """
 | 
			
		||||
    def __init__(self, value):
 | 
			
		||||
        self.value = value
 | 
			
		||||
 | 
			
		||||
    def __eq__(self, other):
 | 
			
		||||
        return other.value == self.value
 | 
			
		||||
 | 
			
		||||
    def __lt__(self, other):
 | 
			
		||||
        return other.value < self.value
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user