doc: update v3.3 release notes draft
[git-cola.git] / bin / git-dag
blob1cc1c34a40a08bbcd963283bd753b292bb8072c7
1 #!/usr/bin/env python
2 """git-dag: An advanced git DAG visualizer
3 """
5 from __future__ import division, absolute_import, unicode_literals
6 import os
7 from os.path import abspath, dirname, join, realpath
8 import sys
11 __copyright__ = """
12 Copyright (C) 2007-2018 David Aguilar and contributors
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License version 2 as
16 published by the Free Software Foundation.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 """
26 def setup_environment():
27 """Provides access to the cola modules"""
29 # Try to detect where it is run from and set prefix and the search path.
30 # It is assumed that the user installed Cola using the --prefix= option
31 python2 = sys.version_info[0] == 2
32 prefix = dirname(dirname(realpath(abspath(__file__))))
34 if python2:
35 cola_mod = join(prefix, str('cola'), str('__init__.py'))
36 install_lib = join(prefix, str('share'), str('git-cola'), str('lib'))
37 else:
38 # Look for modules in the source or install trees
39 cola_mod = os.path.join(prefix, 'cola', '__init__.py')
40 install_lib = os.path.join(prefix, 'share', 'git-cola', 'lib')
42 if os.path.exists(cola_mod):
43 # Source tree
44 sys.path.insert(1, prefix)
45 else:
46 # Install tree
47 sys.path.insert(1, install_lib)
50 setup_environment()
53 if __name__ == '__main__':
54 from cola import dag
55 sys.exit(dag.main())