submodules: address pylint warnings
[git-cola.git] / setup.py
blob5d7ceda60f54983f626a9874cbbb460815e454f3
1 #!/usr/bin/env python
2 # git-cola installer
3 # usage: use the Makefile instead of invoking this script directly.
4 # pylint: disable=import-error,no-name-in-module
5 from __future__ import absolute_import, division, unicode_literals
6 from glob import glob
7 from distutils.command import build_scripts
8 from distutils.core import setup
9 import os
10 import re
11 import sys
13 from extras import cmdclass
15 # Hack: prevent python2's ascii default encoding from breaking inside
16 # distutils when installing from utf-8 paths.
17 if sys.version_info[0] < 3:
18 # pylint: disable=reload-builtin,undefined-variable
19 reload(sys) # noqa
20 # pylint: disable=no-member
21 sys.setdefaultencoding('utf-8')
23 # Prevent distuils from changing "#!/usr/bin/env python" when
24 # --use-env-python is specified.
25 try:
26 sys.argv.remove('--use-env-python')
27 use_env_python = True
28 except ValueError:
29 use_env_python = False
30 if use_env_python:
31 build_scripts.first_line_re = re.compile(r'^should not match$')
33 # Disable installation of the private cola package by passing --no-private-libs or
34 # by setting GIT_COLA_NO_PRIVATE_LIBS=1 in th environment.
35 try:
36 sys.argv.remove('--no-private-libs')
37 private_libs = False
38 except ValueError:
39 private_libs = not os.getenv('GIT_COLA_NO_PRIVATE_LIBS', '')
41 # Disable vendoring of qtpy and friends by passing --no-vendor-libs to setup.py or
42 # by setting GIT_COLA_NO_VENDOR_LIBS=1 in the environment.
43 try:
44 sys.argv.remove('--no-vendor-libs')
45 vendor_libs = False
46 except ValueError:
47 vendor_libs = not os.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
49 here = os.path.dirname(__file__)
50 version = os.path.join(here, 'cola', '_version.py')
51 scope = {}
52 exec(open(version).read(), scope) # pylint: disable=exec-used
53 version = scope['VERSION']
56 def main():
57 """Runs distutils.setup()"""
58 scripts = [
59 'bin/git-cola',
60 'bin/git-cola-sequence-editor',
61 'bin/git-dag',
64 if sys.platform == 'win32':
65 scripts.append('contrib/win32/cola')
67 packages = [str('cola'), str('cola.models'), str('cola.widgets')]
69 setup(
70 name='git-cola',
71 version=version,
72 description='The highly caffeinated git GUI',
73 long_description='A sleek and powerful git GUI',
74 license='GPLv2',
75 author='David Aguilar',
76 author_email='davvid@gmail.com',
77 url='https://git-cola.github.io/',
78 scripts=scripts,
79 cmdclass=cmdclass,
80 packages=packages,
81 platforms='any',
82 data_files=_data_files(),
86 def _data_files():
87 """Return the list of data files"""
88 data = [
89 _app_path('share/git-cola/bin', '*'),
90 _app_path('share/git-cola/icons', '*.png'),
91 _app_path('share/git-cola/icons', '*.svg'),
92 _app_path('share/git-cola/icons/dark', '*.png'),
93 _app_path('share/git-cola/icons/dark', '*.svg'),
94 _app_path('share/appdata', '*.xml'),
95 _app_path('share/applications', '*.desktop'),
96 _app_path('share/doc/git-cola', '*.rst'),
97 _app_path('share/doc/git-cola', '*.html'),
100 if private_libs:
101 data.extend(
102 [_package('cola'), _package('cola.models'), _package('cola.widgets')]
105 if vendor_libs:
106 data.extend([_package('qtpy'), _package('qtpy._patch')])
108 data.extend(
110 _app_path(localedir, 'git-cola.mo')
111 for localedir in glob('share/locale/*/LC_MESSAGES')
114 return data
117 def _package(package, subdirs=None):
118 """Collect python files for a given python "package" name"""
119 dirs = package.split('.')
120 app_dir = _lib_path(*dirs)
121 if subdirs:
122 dirs = list(subdirs) + dirs
123 src_dir = os.path.join(*dirs)
124 return (app_dir, glob(os.path.join(src_dir, '*.py')))
127 def _lib_path(*dirs):
128 return os.path.join('share', 'git-cola', 'lib', *dirs)
131 def _app_path(dirname, entry):
132 """Construct (dirname, [glob-expanded-entries relative to dirname])"""
133 return (dirname, glob(os.path.join(dirname, entry)))
136 if __name__ == '__main__':
137 main()