widgets: add an extension method for model unregistration
[git-cola.git] / setup.py
bloba1ec152c0873128653597054e3c3a1eb1d07da99
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
14 from extras import build_helpers
16 # Hack: prevent python2's ascii default encoding from breaking inside
17 # distutils when installing from utf-8 paths.
18 if sys.version_info[0] < 3:
19 # pylint: disable=reload-builtin,undefined-variable
20 reload(sys) # noqa
21 # pylint: disable=no-member
22 sys.setdefaultencoding('utf-8')
24 # Prevent distuils from changing "#!/usr/bin/env python" when
25 # --use-env-python is specified.
26 try:
27 sys.argv.remove('--use-env-python')
28 use_env_python = True
29 except ValueError:
30 use_env_python = False
31 if use_env_python:
32 build_scripts.first_line_re = re.compile(r'^should not match$')
34 # Disable vendoring of qtpy and friends by passing --no-vendor-libs
35 try:
36 sys.argv.remove('--no-vendor-libs')
37 vendor_libs = False
38 except ValueError:
39 vendor_libs = not os.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
41 here = os.path.dirname(__file__)
42 version = os.path.join(here, 'cola', '_version.py')
43 scope = {}
44 exec(open(version).read(), scope) # pylint: disable=exec-used
45 version = scope['VERSION']
48 def main():
49 """Runs distutils.setup()"""
50 scripts = [
51 'bin/git-cola',
52 'bin/git-dag',
55 if sys.platform == 'win32':
56 scripts.append('contrib/win32/cola')
58 # Helper scripts are installed to share/git-cola/bin and are visible to
59 # git-cola only. Adding scripts to build_helpers.scripts will make them
60 # available for #! updating.
61 build_helpers.helpers = [
62 'share/git-cola/bin/git-xbase',
65 setup(name='git-cola',
66 version=version,
67 description='The highly caffeinated git GUI',
68 long_description='A sleek and powerful git GUI',
69 license='GPLv2',
70 author='David Aguilar',
71 author_email='davvid@gmail.com',
72 url='https://git-cola.github.io/',
73 scripts=scripts,
74 cmdclass=cmdclass,
75 platforms='any',
76 data_files=_data_files())
79 def _data_files():
80 """Return the list of data files"""
81 data = [
82 _app_path('share/git-cola/bin', '*'),
83 _app_path('share/git-cola/icons', '*.png'),
84 _app_path('share/git-cola/icons', '*.svg'),
85 _app_path('share/git-cola/icons/dark', '*.png'),
86 _app_path('share/git-cola/icons/dark', '*.svg'),
87 _app_path('share/appdata', '*.xml'),
88 _app_path('share/applications', '*.desktop'),
89 _app_path('share/doc/git-cola', '*.rst'),
90 _app_path('share/doc/git-cola', '*.html'),
91 _package('cola'),
92 _package('cola.models'),
93 _package('cola.widgets'),
96 if vendor_libs:
97 data.extend([
98 _package('qtpy'),
99 _package('qtpy._patch'),
102 data.extend([_app_path(localedir, 'git-cola.mo')
103 for localedir in glob('share/locale/*/LC_MESSAGES')])
104 return data
107 def _package(package, subdirs=None):
108 """Collect python files for a given python "package" name"""
109 dirs = package.split('.')
110 app_dir = _lib_path(*dirs)
111 if subdirs:
112 dirs = list(subdirs) + dirs
113 src_dir = os.path.join(*dirs)
114 return (app_dir, glob(os.path.join(src_dir, '*.py')))
117 def _lib_path(*dirs):
118 return os.path.join('share', 'git-cola', 'lib', *dirs)
121 def _app_path(dirname, entry):
122 """Construct (dirname, [glob-expanded-entries relative to dirname])"""
123 return (dirname, glob(os.path.join(dirname, entry)))
126 if __name__ == '__main__':
127 main()