summaryrefslogtreecommitdiff
path: root/lib/utils/version.py
blob: 0b46669a943210c4d4285e61e9575ea4f3e90660 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Authors: see git history
#
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later.  See the file LICENSE for details.

import sys
from os.path import isfile, join, realpath

from ..i18n import _


def get_inkstitch_version():
    if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
        if sys.platform == "darwin":
            version = realpath(join(sys._MEIPASS, "..", 'Resources', "VERSION"))
        else:
            version = realpath(join(sys._MEIPASS, "..", "VERSION"))
    else:
        version = realpath(join(realpath(__file__), "..", "..", "..", 'VERSION'))
    if isfile(version):
        with open(version, 'r') as v:
            inkstitch_version = _("Ink/Stitch Version: %s") % v.readline()
    else:
        inkstitch_version = _("Ink/Stitch Version: unknown")
    return inkstitch_version