#!/usr/bin/env python
"""git-cola: The highly caffeinated Git GUI"""
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import sys


__copyright__ = """
Copyright (C) 2007-2020 David Aguilar and contributors

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program 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 General Public License for more details.

"""


def setup_environment():
    """Provide access to the cola modules"""
    abspath = os.path.abspath(__file__)
    prefix = os.path.dirname(os.path.dirname(os.path.realpath(abspath)))
    install_lib = os.path.join(prefix, str('share'), str('git-cola'), str('lib'))
    win_pkgs = os.path.join(prefix, str('pkgs'))
    # Use the private modules from share/git-cola/lib when they exist.
    # It is assumed that that our modules to be present in sys.path through python's
    # site-packages directory when the private modules do not exist.
    if os.path.exists(install_lib):
        sys.path.insert(1, install_lib)
    elif os.path.exists(win_pkgs):
        sys.path.insert(1, win_pkgs)


if __name__ == '__main__':
    setup_environment()
    from cola.main import main

    sys.exit(main())
