git-cola 1.7.4
[git-cola.git] / setup.py
blob86b8c58e666b8cdd0170171eb22a46f68abd0d98
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.prefs'),
112 _package('cola.stash'),
113 _package('cola.widgets'),
116 data.extend([_app_path(localedir, 'git-cola.mo')
117 for localedir in glob('share/locale/*/LC_MESSAGES')])
119 if sys.platform == 'darwin':
120 data.append(_app_path('share/git-cola/bin', 'ssh-askpass-darwin'))
121 else:
122 data.append(_app_path('share/git-cola/bin', 'ssh-askpass'))
123 return data
126 def _package(package, subdir=None):
127 subdirs = package.split('.')
128 app_dir = os.path.join('share', 'git-cola', 'lib', *subdirs)
129 if subdir:
130 subdirs.insert(0, subdir)
131 src_dir = os.path.join(*subdirs)
132 return (app_dir, glob(os.path.join(src_dir, '*.py')))
135 def _app_path(dirname, entry):
136 return (dirname, glob(os.path.join(dirname, entry)))
139 if __name__ == '__main__':
140 main()