Revision 450e0a22

b/snf-app/setup.py
40 40
from distutils.util import convert_path
41 41
from fnmatch import fnmatchcase
42 42
from setuptools import setup, find_packages
43
from synnefo import get_version
43
from synnefo.version import get_version
44 44

  
45 45
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
46 46

  
b/snf-app/synnefo/__init__.py
1
VERSION = (0, 8, 0, 'alpha', 0)
2
__version__ = VERSION
3

  
4
def get_version():
5
    version = '%s.%s' % (VERSION[0], VERSION[1])
6
    if VERSION[2]:
7
        version = '%s.%s' % (version, VERSION[2])
8
    if VERSION[3:] == ('alpha', 0):
9
        version = '%s pre-alpha' % version
10
    else:
11
        if VERSION[3] != 'final':
12
            version = '%s %s %s' % (version, VERSION[3], VERSION[4])
13
    return version
1
# this is a namespace package
2
try:
3
    import pkg_resources
4
    pkg_resources.declare_namespace(__name__)
5
except ImportError:
6
    import pkgutil
7
    __path__ = pkgutil.extend_path(__path__, __name__)
b/snf-app/synnefo/version.py
1
VERSION = (0, 8, 0, 'alpha', 0)
2
__version__ = VERSION
3

  
4
def get_version():
5
    """
6
    Utility to parse version tuple to string
7
    """
8
    version = '%s.%s' % (VERSION[0], VERSION[1])
9
    if VERSION[2]:
10
        version = '%s.%s' % (version, VERSION[2])
11
    if VERSION[3:] == ('alpha', 0):
12
        version = '%s pre-alpha' % version
13
    else:
14
        if VERSION[3] != 'final':
15
            version = '%s %s %s' % (version, VERSION[3], VERSION[4])
16
    return version
17

  
18
def vcs_version():
19
    """
20
    Return current git HEAD commit information
21
    """
22
    import subprocess
23
    callgit = lambda(cmd): subprocess.Popen(
24
            ['/bin/sh', '-c', cmd],
25
            stdout=subprocess.PIPE).communicate()[0].strip()
26

  
27
    branch = callgit('git branch | grep -Ei "\* (.*)" | cut -f2 -d" "')
28
    revid = callgit("git --no-pager log --max-count=1 | cut -f2 -d' ' | head -1")
29
    revno = callgit('git --no-pager log --oneline | wc -l')
30

  
31
    return branch, revid, revno
32

  

Also available in: Unified diff