prefs: apply flake8 suggestions
[git-cola.git] / setup.py
blob1f2261dd4618d23813f162a513246a5c9a8ed5f7
1 #!/usr/bin/env python
3 from __future__ import absolute_import, division, unicode_literals
5 # Hacktastic hack to fix python's stupid ascii default encoding, which
6 # breaks inside distutils when installing from utf-8 paths.
7 import sys
8 try:
9 # pylint: disable=reload-builtin
10 reload(sys)
11 sys.setdefaultencoding('utf-8')
12 except NameError: # Python3
13 pass
16 import os
17 from glob import glob
18 from distutils.core import setup
20 # Look for modules in the root
21 srcdir = os.path.dirname(os.path.abspath(__file__))
23 from extras import cmdclass
25 here = os.path.dirname(__file__)
26 version = os.path.join(here, 'cola', '_version.py')
27 scope = {}
28 exec(open(version).read(), scope)
29 version = scope['VERSION']
32 def main():
33 """Runs distutils.setup()"""
35 scripts = [
36 'bin/git-cola',
37 'bin/git-dag',
40 if sys.platform == 'win32':
41 scripts.append('contrib/win32/cola')
43 setup(name='git-cola',
44 version=version,
45 description='The highly caffeinated git GUI',
46 long_description='A sleek and powerful git GUI',
47 license='GPLv2',
48 author='David Aguilar',
49 author_email='davvid@gmail.com',
50 url='https://git-cola.github.io/',
51 scripts=scripts,
52 cmdclass=cmdclass,
53 platforms='any',
54 data_files = cola_data_files())
56 def cola_data_files():
57 data = [
58 _app_path('share/git-cola/bin', '*'),
59 _app_path('share/git-cola/icons', '*.png'),
60 _app_path('share/git-cola/icons', '*.svg'),
61 _app_path('share/applications', '*.desktop'),
62 _app_path('share/doc/git-cola', '*.rst'),
63 _app_path('share/doc/git-cola', '*.html'),
64 _package('cola'),
65 _package('cola.models'),
66 _package('cola.widgets'),
69 data.extend([_app_path(localedir, 'git-cola.mo')
70 for localedir in glob('share/locale/*/LC_MESSAGES')])
71 return data
74 def _package(package, subdir=None):
75 subdirs = package.split('.')
76 app_dir = os.path.join('share', 'git-cola', 'lib', *subdirs)
77 if subdir:
78 subdirs.insert(0, subdir)
79 src_dir = os.path.join(*subdirs)
80 return (app_dir, glob(os.path.join(src_dir, '*.py')))
83 def _app_path(dirname, entry):
84 return (dirname, glob(os.path.join(dirname, entry)))
87 if __name__ == '__main__':
88 main()