main: pass the context to browse_recent_files
[git-cola.git] / setup.py
blobb4cd1f125d757391f7b05960a32162d6f63ebdea
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
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('^should not match$')
33 # Disable vendoring of qtpy and friends by passing --no-vendor-libs
34 try:
35 sys.argv.remove('--no-vendor-libs')
36 vendor_libs = False
37 except ValueError:
38 vendor_libs = not os.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
40 here = os.path.dirname(__file__)
41 version = os.path.join(here, 'cola', '_version.py')
42 scope = {}
43 exec(open(version).read(), scope) # pylint: disable=exec-used
44 version = scope['VERSION']
47 def main():
48 """Runs distutils.setup()"""
49 scripts = [
50 'bin/git-cola',
51 'bin/git-dag',
54 if sys.platform == 'win32':
55 scripts.append('contrib/win32/cola')
57 setup(name='git-cola',
58 version=version,
59 description='The highly caffeinated git GUI',
60 long_description='A sleek and powerful git GUI',
61 license='GPLv2',
62 author='David Aguilar',
63 author_email='davvid@gmail.com',
64 url='https://git-cola.github.io/',
65 scripts=scripts,
66 cmdclass=cmdclass,
67 platforms='any',
68 data_files=_data_files())
71 def _data_files():
72 """Return the list of data files"""
73 data = [
74 _app_path('share/git-cola/bin', '*'),
75 _app_path('share/git-cola/icons', '*.png'),
76 _app_path('share/git-cola/icons', '*.svg'),
77 _app_path('share/git-cola/icons/dark', '*.png'),
78 _app_path('share/git-cola/icons/dark', '*.svg'),
79 _app_path('share/appdata', '*.xml'),
80 _app_path('share/applications', '*.desktop'),
81 _app_path('share/doc/git-cola', '*.rst'),
82 _app_path('share/doc/git-cola', '*.html'),
83 _package('cola'),
84 _package('cola.models'),
85 _package('cola.widgets'),
88 if vendor_libs:
89 data.extend([
90 _package('qtpy'),
91 _package('qtpy._patch'),
94 data.extend([_app_path(localedir, 'git-cola.mo')
95 for localedir in glob('share/locale/*/LC_MESSAGES')])
96 return data
99 def _package(package, subdirs=None):
100 """Collect python files for a given python "package" name"""
101 dirs = package.split('.')
102 app_dir = _lib_path(*dirs)
103 if subdirs:
104 dirs = list(subdirs) + dirs
105 src_dir = os.path.join(*dirs)
106 return (app_dir, glob(os.path.join(src_dir, '*.py')))
109 def _lib_path(*dirs):
110 return os.path.join('share', 'git-cola', 'lib', *dirs)
113 def _app_path(dirname, entry):
114 """Construct (dirname, [glob-expanded-entries relative to dirname])"""
115 return (dirname, glob(os.path.join(dirname, entry)))
118 if __name__ == '__main__':
119 main()