finder: use the background editor
[git-cola.git] / setup.py
blob806b2129eaef322106ac02984bae5a0addf680e9
1 #!/usr/bin/env python
2 """git-cola installer
4 NOTE: This script is not typically invoked directly; use the Makefile
5 targets instead.
7 """
9 from __future__ import absolute_import, division, unicode_literals
11 # Hacktastic hack to fix python's stupid ascii default encoding, which
12 # breaks inside distutils when installing from utf-8 paths.
13 import sys
14 try:
15 # pylint: disable=reload-builtin
16 reload(sys)
17 # pylint: disable=no-member
18 sys.setdefaultencoding('utf-8')
19 except NameError: # Python3
20 pass
22 import os
23 from glob import glob
24 from distutils.core import setup
26 # Look for modules in the root
27 srcdir = os.path.dirname(os.path.abspath(__file__))
29 from extras import cmdclass
31 here = os.path.dirname(__file__)
32 version = os.path.join(here, 'cola', '_version.py')
33 scope = {}
34 exec(open(version).read(), scope) # pylint: disable=exec-used
35 version = scope['VERSION']
38 def main():
39 """Runs distutils.setup()"""
40 vendor_libs = should_vendor_libs()
42 scripts = [
43 'bin/git-cola',
44 'bin/git-dag',
47 if sys.platform == 'win32':
48 scripts.append('contrib/win32/cola')
50 setup(name='git-cola',
51 version=version,
52 description='The highly caffeinated git GUI',
53 long_description='A sleek and powerful git GUI',
54 license='GPLv2',
55 author='David Aguilar',
56 author_email='davvid@gmail.com',
57 url='https://git-cola.github.io/',
58 scripts=scripts,
59 cmdclass=cmdclass,
60 platforms='any',
61 data_files=_data_files(vendor_libs))
64 def should_vendor_libs():
65 """Return True if we should include vendored libraries"""
66 vendor_libs = not os.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
67 if '--no-vendor-libs' in sys.argv:
68 sys.argv.remove('--no-vendor-libs')
69 vendor_libs = False
70 return vendor_libs
73 def _data_files(vendor_libs):
74 """Return the list of data files"""
75 data = [
76 _app_path('share/git-cola/bin', '*'),
77 _app_path('share/git-cola/icons', '*.png'),
78 _app_path('share/git-cola/icons', '*.svg'),
79 _app_path('share/git-cola/icons/dark', '*.png'),
80 _app_path('share/git-cola/icons/dark', '*.svg'),
81 _app_path('share/appdata', '*.xml'),
82 _app_path('share/applications', '*.desktop'),
83 _app_path('share/doc/git-cola', '*.rst'),
84 _app_path('share/doc/git-cola', '*.html'),
85 _package('cola'),
86 _package('cola.models'),
87 _package('cola.widgets'),
90 if vendor_libs:
91 data.extend([
92 _package('qtpy'),
93 _package('qtpy._patch'),
96 data.extend([_app_path(localedir, 'git-cola.mo')
97 for localedir in glob('share/locale/*/LC_MESSAGES')])
98 return data
101 def _package(package, subdirs=None):
102 """Collect python files for a given python "package" name"""
103 dirs = package.split('.')
104 app_dir = _lib_path(*dirs)
105 if subdirs:
106 dirs = list(subdirs) + dirs
107 src_dir = os.path.join(*dirs)
108 return (app_dir, glob(os.path.join(src_dir, '*.py')))
111 def _lib_path(*dirs):
112 return os.path.join('share', 'git-cola', 'lib', *dirs)
115 def _app_path(dirname, entry):
116 """Construct (dirname, [glob-expanded-entries relative to dirname])"""
117 return (dirname, glob(os.path.join(dirname, entry)))
120 if __name__ == '__main__':
121 main()