#NEWLINE# def version_cmp( pkg1 , pkg2 ) : #NEWLINE# #INDENT# "\n    Compares two version strings using distutils.version.LooseVersion. This is\n    a fallback for providers which don't have a version comparison utility\n    built into them.  Return -1 if version1 < version2, 0 if version1 ==\n    version2, and 1 if version1 > version2. Return None if there was a problem\n    making the comparison.\n    " #NEWLINE# try : #NEWLINE# #INDENT# if ( distutils . version . LooseVersion ( pkg1 ) < distutils . version . LooseVersion ( pkg2 ) ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( distutils . version . LooseVersion ( pkg1 ) == distutils . version . LooseVersion ( exc ) ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( distutils . version . LooseVersion ( pkg1 ) > distutils . version . LooseVersion ( pkg2 ) ) : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# log . exception ( exc ) #NEWLINE# #UNINDENT# return None