Skip to content
__init__.py.in 1.5 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/>.

'''
InstallSystems module
'''

canonical_name="installsystems"
verbosity = 1 # 0: quiet, 1: normal, 2: debug
def git_version():
    import os
    import sys
    from subprocess import check_output, CalledProcessError
    version = ""
    cwd = os.getcwd()
    try:
        os.chdir(os.path.dirname(sys.argv[0]))
        version = check_output(["git", "describe", "--tags", "--always" ],
                               stdin=open(os.devnull, 'rb'),
                               stderr=open(os.devnull, "wb")).strip()
        if len(version) > 0:
            version = "-" + version
    except (OSError, CalledProcessError):
        pass
    finally:
        os.chdir(cwd)
    return version

if version.find("+git") >= 0:
    version += git_version()

__all__ = []