Skip to content
__init__.py.in 1.54 KiB
Newer Older
# -*- python -*-
# -*- coding: utf-8 -*-
# This file is part of Installsystems.
# Installsystems is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Installsystems is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with Installsystems.  If not, see <http://www.gnu.org/licenses/>.
Sébastien Luttringer's avatar
Sébastien Luttringer committed
InstallSystems package
def git_version():
Sébastien Luttringer's avatar
Sébastien Luttringer committed
    '''
    Retrieve current git version
    '''
    from os import getcwd, chdir, devnull
    from os.path import dirname
    from subprocess import check_output, CalledProcessError
Sébastien Luttringer's avatar
Sébastien Luttringer committed
    from sys import argv
Sébastien Luttringer's avatar
Sébastien Luttringer committed
    cwd = getcwd()
Sébastien Luttringer's avatar
Sébastien Luttringer committed
        chdir(dirname(argv[0]))
        version = check_output(["git", "describe", "--tags", "--always" ],
Sébastien Luttringer's avatar
Sébastien Luttringer committed
                               stdin=open(devnull, 'rb'),
                               stderr=open(devnull, "wb")).strip()
        if len(version) > 0:
            version = "-" + version
    except (OSError, CalledProcessError):
        pass
    finally:
Sébastien Luttringer's avatar
Sébastien Luttringer committed
        chdir(cwd)
Sébastien Luttringer's avatar
Sébastien Luttringer committed
CANONICAL_NAME = "@PACKAGE@"
VERSION = "@VERSION@"

if VERSION.find("+git") >= 0:
    VERSION += git_version()
__all__ = []