def __closestVersion__(_requiredString,versions,package): 
    """Finds the closes matching version when exact version not available, raises error if requirement cannot be satisfied,
        specifying the depth of the error, eg. Major.Minor.etc.
    
        Some debug output to illustrate wtf is going on.
        Determine best match for 0_5_0 in ['PythonMagick_0_4_0', 'PythonMagick_0_4_9', 'PythonMagick_0_5_0']
        [
            [0, [0, 4, 0], 'PythonMagick_0_4_0', 0],
            [0, [0, 4, 9], 'PythonMagick_0_4_9', 0],
            [0, [0, 5, 0], 'PythonMagick_0_5_0', 0]
        ]
         
        where: [score, [versionDigits], package, errorsDepth] = each item in collection   
    """
    global _debug
    _requiredString = _requiredString.replace('_','.')
    _required = _requiredString.split('.') #convert dotted to underscored / split on underscores
    _tolerance = len( _required )
    if _debug: print '[%s] Determine best match for %s in %s' % (package, _requiredString, versions)
    
    ##Build sortMatrix
    _sortMatrix = []
    for item in versions: 
        _version = item.replace(package + '_','').replace('.','_').split('_') #strip the package prefix
        #for i in range(0,len(_version)): _version[i] = int(_version[i]) #covert to numeric
        #_version = filter(int,_version)#covert to numeric
        _this = [ 0, _version, item ]
        _sortMatrix.append(_this)
        
    ##Iterate sort matrix scoring available packages
    #_required = filter(int,_required)#covert to numeric
    for i in range(0,len(_sortMatrix)): #traverse Matrix giving scores
        j, _stop = 0, 0 #drill into each point performing comparisons
        while j < len(_required) and not(_stop):
            if len(_sortMatrix[i][1]) > j and _sortMatrix[i][1][j] == _required[j]: _sortMatrix[i][0] += 1 #increment score if levelMatch avaliable / found
            else: _stop = 1 #incompatible from here on in
            j += 1 #keep drilling
    
    ##Select best match from sort matrix
    _score, _latest = 0, None 
    for i in range(0,len(_sortMatrix)):#select highest available compatible version, with the highest score
        if _sortMatrix[i][0] >= _score: #if same score but higher version, or higher score
            _score = _sortMatrix[i][0] #Set highscore
            _latest = _sortMatrix[i][2] #Package Name and version
    if _latest and _score >= len( _required ):
        return _latest, _versioningMap[_score]
    else:
        errorDescription = '\n\t[%s v%s] not avaliable: could not find %s \n\tVersion String Example: %s (non integers are stripped)' % ( package, _requiredString, _versioningMap[_score], _versionExample )
        raise Exception, errorDescription
Finds the closes matching version when exact version not available, raises error if requirement cannot be satisfied,
        specifying the depth of the error, eg. Major.Minor.etc.
    
        Some debug output to illustrate wtf is going on.
        Determine best match for 0_5_0 in ['PythonMagick_0_4_0', 'PythonMagick_0_4_9', 'PythonMagick_0_5_0']
        [
            [0, [0, 4, 0], 'PythonMagick_0_4_0', 0],
            [0, [0, 4, 9], 'PythonMagick_0_4_9', 0],
            [0, [0, 5, 0], 'PythonMagick_0_5_0', 0]
        ]
         
        where: [score, [versionDigits], package, errorsDepth] = each item in collection   
    
recipes/Python/285215_Package__Module_Versioning_Bootstrap_Loader_/recipe-285215.py