difftool: use the `git` object instead of subprocess directly
[git-cola.git] / bin / git-cola
blobda774779663d5784d6d1649fcf0e731617d12112
1 #!/usr/bin/env python
2 # -*- python-mode -*-
3 """git-cola: The highly caffeinated Git GUI
4 """
6 from __future__ import division, absolute_import, unicode_literals
8 __copyright__ = """
9 Copyright (C) 2007-2015
10 David Aguilar <davvid@gmail.com> and contributors
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License version 2 as
14 published by the Free Software Foundation.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 """
23 import os
24 import sys
25 from os.path import abspath
26 from os.path import dirname
27 from os.path import join
28 from os.path import realpath
31 def setup_environment():
32 """Provides access to the cola modules"""
33 # Try to detect where it is run from and set prefix and the search path.
34 # It is assumed that the user installed Cola using the --prefix= option
35 python2 = sys.version_info[0] == 2
36 prefix = dirname(dirname(realpath(abspath(__file__))))
37 if python2:
38 cola_mod = join(prefix, str('cola'), str('__init__.py'))
39 install_lib = join(prefix, str('share'), str('git-cola'), str('lib'))
40 else:
41 # Look for modules in the source or install trees
42 cola_mod = os.path.join(prefix, 'cola', '__init__.py')
43 install_lib = os.path.join(prefix, 'share', 'git-cola', 'lib')
45 if os.path.exists(cola_mod):
46 # Source tree
47 sys.path.insert(1, prefix)
48 else:
49 # Install tree
50 sys.path.insert(1, install_lib)
51 setup_environment()
53 from cola.main import main
55 if __name__ == '__main__':
56 sys.exit(main())