3 """Determine the version number of the current tree.
5 This should be run after 'setup.py darcsver'. It will emit a single line of text
6 to stdout, either of the form '0.2.0' if this is a release tree (i.e. no patches
7 have been added since the last release tag), or '0.2.0-34' (if 34 patches have
8 been added since the last release tag). If the tree does not have a well-formed
9 version number, this will emit 'unknown'.
11 The version string thus calculated should exactly match the version string
12 determined by setup.py (when it creates eggs and source tarballs) and also
13 the version available in the code image when you do:
15 from allmydata import __version__
22 VERSIONFILE = "src/allmydata/_version.py"
24 if os.path.exists(VERSIONFILE):
25 VSRE = re.compile("^verstr = ['\"]([^'\"]*)['\"]", re.M)
26 verstrline = open(VERSIONFILE, "rt").read()
27 mo = VSRE.search(verstrline)
31 raise ValueError("if version.py exists, it must be well-formed")
35 if __name__ == '__main__':
36 verstr = get_version()