Author: bugman Date: Tue Sep 2 14:42:33 2014 New Revision: 25547 URL: http://svn.gna.org/viewcvs/relax?rev=25547&view=rev Log: Merged revisions 25545 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r25545 | bugman | 2014-09-02 14:17:50 +0200 (Tue, 02 Sep 2014) | 8 lines Another fix for the minfx version checking in the dep_check module. The version_comparison() function has been created to perform a proper version number comparison by stripping trailing zeros, converting the two version numbers to lists of int and comparing the lists using the Python cmp() function. This will return -1 when the version number is too low, 0 when the versions are equal, and 1 when the version is higher than the minimum. ........ Modified: branches/frame_order_cleanup/ (props changed) branches/frame_order_cleanup/dep_check.py Propchange: branches/frame_order_cleanup/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Sep 2 14:42:33 2014 @@ -1 +1 @@ -/trunk:1-25537 +/trunk:1-25545 Modified: branches/frame_order_cleanup/dep_check.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/dep_check.py?rev=25547&r1=25546&r2=25547&view=diff ============================================================================== --- branches/frame_order_cleanup/dep_check.py (original) +++ branches/frame_order_cleanup/dep_check.py Tue Sep 2 14:42:33 2014 @@ -28,7 +28,38 @@ # Python modules. import platform from os import F_OK, access, sep +from re import sub import sys + + +def version_comparison(version1, version2): + """Compare software versions. + + This will return: + + - When version 1 is older, -1, + - When both versions are equal, 0, + - When version 1 is newer, 1. + + + @param version1: The first version number. + @type version1: str + @param version2: The second version number. + @type version2: str + @return: The comparison result of the Python cmp() function applied to two lists of integers. This will be one of [-1, 0, 1]. + @type return: int + """ + + # Strip out trailing zeros. + version1 = sub(r'(\.0+)*$','', version1) + version2 = sub(r'(\.0+)*$','', version2) + + # Convert to a list of numbers. + version1 = [int(val) for val in version1.split('.')] + version2 = [int(val) for val in version2.split('.')] + + # Return the comparison. + return cmp(version1, version2) # Essential packages. @@ -54,8 +85,8 @@ # Minfx python package check. try: import minfx - ver = minfx.__version__.split('.') - if not (minfx.__version__ == 'trunk' or not (int(ver[0]) <= 1 and int(ver[1]) <= 0 and int(ver[2]) <= 9)): + min_version = '1.0.9' + if not minfx.__version__ == 'trunk' and version_comparison(minfx.__version__, min_version) == -1: sys.stderr.write("Version %s of the 'minfx' dependency is too old, minfx >= 1.0.9 is required.\n" % minfx.__version__) sys.exit() except ImportError: