forked from git-cola/git-cola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·125 lines (100 loc) · 3.34 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python
import os
import sys
import platform
from glob import glob
from distutils.core import setup
# Look for modules in the root
srcdir = os.path.dirname(os.path.abspath(__file__))
from extras import cmdclass
from cola import version
def main():
_check_python_version()
_check_git_version()
_check_pyqt_version()
_run_setup()
def _check_python_version():
"""Check the minimum Python version
"""
pyver = platform.python_version()
if not version.check('python', pyver):
print >> sys.stderr, ('Python version %s or newer required. '
'Found %s' % (version.get('python'), pyver))
sys.exit(1)
def _check_git_version():
"""Check the minimum GIT version
"""
git_version = version.git_version()
if not version.check('git', git_version):
print >> sys.stderr, ('GIT version %s or newer required. '
'Found %s' % (version.get('git'), git_version))
sys.exit(1)
def _check_pyqt_version():
"""Check the minimum PyQt version
"""
pyqtver = 'None'
try:
from PyQt4 import QtCore
pyqtver = QtCore.PYQT_VERSION_STR
if version.check('pyqt', pyqtver):
return
except ImportError:
pass
print >> sys.stderr, ('PyQt4 version %s or newer required. '
'Found %s' % (version.get('pyqt'), pyqtver))
sys.exit(1)
def _run_setup():
"""Runs distutils.setup()"""
scripts = [
'bin/git-cola',
'bin/git-dag',
]
if sys.platform == 'win32':
scripts.append('win32/cola')
setup(name='git-cola',
version=version.version(),
description='The highly caffeinated git GUI',
long_description='A sleek and powerful git GUI',
license='GPLv2',
author='David Aguilar',
author_email='[email protected]',
url='http://git-cola.github.com/',
scripts=scripts,
cmdclass=cmdclass,
platforms='any',
data_files = cola_data_files())
def cola_data_files():
data = [
_app_path('share/git-cola/icons', '*.png'),
_app_path('share/git-cola/icons', '*.svg'),
_app_path('share/applications', '*.desktop'),
_app_path('share/doc/git-cola', '*.txt'),
_app_path('share/doc/git-cola', '*.html'),
_package('cola'),
_package('cola.classic'),
_package('cola.dag'),
_package('cola.main'),
_package('cola.merge'),
_package('cola.models'),
_package('cola.prefs'),
_package('cola.stash'),
_package('cola.widgets'),
]
data.extend([_app_path(localedir, 'git-cola.mo')
for localedir in glob('share/locale/*/LC_MESSAGES')])
if sys.platform == 'darwin':
data.append(_app_path('share/git-cola/bin', 'ssh-askpass-darwin'))
else:
data.append(_app_path('share/git-cola/bin', 'ssh-askpass'))
return data
def _package(package, subdir=None):
subdirs = package.split('.')
app_dir = os.path.join('share', 'git-cola', 'lib', *subdirs)
if subdir:
subdirs.insert(0, subdir)
src_dir = os.path.join(*subdirs)
return (app_dir, glob(os.path.join(src_dir, '*.py')))
def _app_path(dirname, entry):
return (dirname, glob(os.path.join(dirname, entry)))
if __name__ == '__main__':
main()