version_pep440.diff

planetmaker, 2015-04-10 14:00

Download (2.24 KB)

View differences:

nml/version_info.py
37 37
    path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
38 38
    version = ''
39 39
    if os.path.isdir(os.path.join(path,'.hg')):
40
        # Define the next version released from this branch
41
        next_release_version = '0.4.0'
42
        # we want to return to where we were. So save the old path
40
        # We want to get the actual hash, too and see whether we run a modified checkout
43 41
        try:
44 42
            version_list = get_child_output(['hg', '-R', path, 'id', '-n', '-t', '-i'])
45 43
        except OSError as e:
......
51 49
            modified = ''
52 50
        hash = version_list[0].rstrip('+')
53 51

  
54
        # Get the date of the commit of the current NML version in days since January 1st 2000
55
        ctimes = get_child_output(["hg", "-R", path, "parent", "--template='{date|hgdate} {date|shortdate}\n'"])
56
        ctime = (int((ctimes[0].split("'"))[1]) - 946684800) // (60 * 60 * 24)
57
        revision = str(ctime) # version_list[1].rstrip('+')
52
        # Test whether we have a tag (=release version) and use it, if found
53
        if len(version_list) > 2 and version_list[2] != 'tip' and modified == '':
54
            version = '{}'.format(version_list[2])
55
            return version
58 56

  
59
        # Combine the version string
60
        version += "{}.r{}{}:{} from {}".format(next_release_version, revision, modified, hash, ctimes[2].split("'", 1)[0])
57
        # Define the version from the last tag in the list of ancestors and the time of the current checkout
58
        version_info = get_child_output(["hg", "-R", path, "parent", "--template='{branch} {latesttag} {latesttagdistance} {date|shortdate}\n'"])
61 59

  
62
        # Test whether we have a tag (=release version) and add it, if found
63
        if len(version_list) > 2 and version_list[2] != 'tip' and modified == '':
64
            version += ' (Released as {})'.format(version_list[2])
60
        # Combine the version string to Python standard version format (see PEP 440)
61
        version += "{}.post{}+{}-{}{}.{}".format(version_info[1], version_info[2], version_info[0].split("'", 1)[1], hash, modified, version_info[3].split("'", 1)[0])
62

  
65 63
    return version
66 64

  
67 65
def get_lib_versions():