source: sasview/build_tools/get_version.py @ 8a9f699

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 8a9f699 was 0cbdaf0, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #3 improve versioning

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import os
2__revision__ = "0"
3__version__ = "0.0.0"
4   
5def get_svn_revision(path=None):
6    rev = None
7    if path is None:
8        path = os.path.dirname(__file__)
9    entries_path = '%s/.svn/entries' % path
10
11    if os.path.exists(entries_path):
12        entries = open(entries_path, 'r').read()
13        # Versions >= 7 of the entries file are flat text.  The first line is
14        # the version number. The next set of digits after 'dir' is the revision.
15        if re.match('(\d+)', entries):
16            rev_match = re.search('\d+\s+dir\s+(\d+)', entries)
17            if rev_match:
18                rev = rev_match.groups()[0]
19        # Older XML versions of the file specify revision as an attribute of
20        # the first entries node.
21        else:
22            from xml.dom import minidom
23            dom = minidom.parse(entries_path)
24            rev = dom.getElementsByTagName('entry')[0].getAttribute('revision')
25
26    if rev:
27        return u'%s' % rev
28    return None
29
30# Get the version number from the sansview module
31# Check to see if we are dealing with a release
32try:
33    import sans.sansview
34    __version__ = sans.sansview.__version__
35    __revision__ = sans.sansview.__build__
36except:
37    print "Could not load sansview module"
38
39# Get actual revision number if possible
40try:
41    rev = get_svn_revision()
42    if rev is not None:
43        __revision__ = rev
44except:
45    print "Could not extract revision number"
46
47
48print "SansView v ", __version__, __revision__
Note: See TracBrowser for help on using the repository browser.