app: Make `git cola dag` a valid invocation
[git-cola.git] / setup.py
blobdb4779bad263582a0ff23171a147efe6c76fff72
1 #!/usr/bin/env python
3 import os
4 import sys
5 import platform
6 from glob import glob
7 from distutils.core import setup
9 # Look for modules in the root
10 srcdir = os.path.dirname(os.path.abspath(__file__))
12 from extras import cmdclass
13 from cola import version
16 def main():
17 _check_python_version()
18 _setup_environment()
19 _check_git_version()
20 _check_pyqt_version()
21 _run_setup()
24 def _check_python_version():
25 """Check the minimum Python version
26 """
27 pyver = platform.python_version()
28 if not version.check('python', pyver):
29 print >> sys.stderr, ('Python version %s or newer required. '
30 'Found %s' % (version.get('python'), pyver))
31 sys.exit(1)
34 def _setup_environment():
35 """Adds win32/ to our path for windows only"""
36 if sys.platform != 'win32':
37 return
38 path = os.environ['PATH']
39 win32 = os.path.join(srcdir, 'win32')
40 os.environ['PATH'] = win32 + os.pathsep + path
43 def _check_git_version():
44 """Check the minimum GIT version
45 """
46 git_version = version.git_version()
47 if not version.check('git', git_version):
48 print >> sys.stderr, ('GIT version %s or newer required. '
49 'Found %s' % (version.get('git'), git_version))
50 sys.exit(1)
53 def _check_pyqt_version():
54 """Check the minimum PyQt version
55 """
56 pyqtver = 'None'
57 try:
58 from PyQt4 import QtCore
59 pyqtver = QtCore.PYQT_VERSION_STR
60 if version.check('pyqt', pyqtver):
61 return
62 except ImportError:
63 pass
64 print >> sys.stderr, ('PyQt4 version %s or newer required. '
65 'Found %s' % (version.get('pyqt'), pyqtver))
66 sys.exit(1)
69 def _run_setup():
70 """Runs distutils.setup()"""
72 scripts = [
73 'bin/git-cola',
74 'bin/git-dag',
77 if sys.platform == 'win32':
78 scripts.extend([
79 'win32/cola',
80 'win32/dirname',
81 'win32/py2exe-setup.py',
82 'win32/py2exe-setup.cmd',
85 setup(name = 'git-cola',
86 version = version.version(),
87 description = 'The highly caffeinated git GUI',
88 license = 'GPLv2',
89 author = 'The git-cola community',
90 author_email = 'git-cola@googlegroups.com',
91 url = 'http://git-cola.github.com/',
92 long_description = 'A sleek and powerful git GUI',
93 scripts = scripts,
94 cmdclass = cmdclass,
95 data_files = cola_data_files())
98 def cola_data_files():
99 data = [
100 _app_path('share/git-cola/icons', '*.png'),
101 _app_path('share/git-cola/icons', '*.svg'),
102 _app_path('share/applications', '*.desktop'),
103 _app_path('share/doc/git-cola', '*.txt'),
104 _app_path('share/doc/git-cola', '*.html'),
105 _package('cola'),
106 _package('cola.classic'),
107 _package('cola.dag'),
108 _package('cola.main'),
109 _package('cola.merge'),
110 _package('cola.models'),
111 _package('cola.controllers'),
112 _package('cola.prefs'),
113 _package('cola.stash'),
114 _package('cola.views'),
115 _package('cola.widgets'),
118 data.extend([_app_path(localedir, 'git-cola.mo')
119 for localedir in glob('share/locale/*/LC_MESSAGES')])
121 if sys.platform == 'darwin':
122 data.append(_app_path('share/git-cola/bin', 'ssh-askpass-darwin'))
123 else:
124 data.append(_app_path('share/git-cola/bin', 'ssh-askpass'))
125 return data
128 def _package(package, subdir=None):
129 subdirs = package.split('.')
130 app_dir = os.path.join('share', 'git-cola', 'lib', *subdirs)
131 if subdir:
132 subdirs.insert(0, subdir)
133 src_dir = os.path.join(*subdirs)
134 return (app_dir, glob(os.path.join(src_dir, '*.py')))
137 def _app_path(dirname, entry):
138 return (dirname, glob(os.path.join(dirname, entry)))
141 if __name__ == '__main__':
142 main()