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
7 from distutils
.command
import build_scripts
8 from distutils
.core
import setup
13 sys
.path
.insert(1, os
.path
.dirname(__file__
))
14 from extras
import cmdclass
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
21 # pylint: disable=no-member
22 sys
.setdefaultencoding('utf-8')
24 # Prevent distutils from changing "#!/usr/bin/env python" when
25 # --use-env-python is specified.
27 sys
.argv
.remove('--use-env-python')
30 use_env_python
= False
32 if sys
.version_info
[0] < 3:
33 # Python2 accepts the r'' unicode literal.
34 pattern
= re
.compile(r
'^should not match$')
36 # Python3 reads files as bytes and requires that the regex pattern is
38 pattern
= re
.compile(b
'^should not match$')
39 build_scripts
.first_line_re
= pattern
41 # Disable installation of the private cola package by passing --no-private-libs or
42 # by setting GIT_COLA_NO_PRIVATE_LIBS=1 in th environment.
44 sys
.argv
.remove('--no-private-libs')
47 private_libs
= not os
.getenv('GIT_COLA_NO_PRIVATE_LIBS', '')
49 # Disable vendoring of qtpy and friends by passing --no-vendor-libs to setup.py or
50 # by setting GIT_COLA_NO_VENDOR_LIBS=1 in the environment.
52 sys
.argv
.remove('--no-vendor-libs')
55 vendor_libs
= not os
.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
58 here
= os
.path
.dirname(__file__
)
59 version
= os
.path
.join(here
, 'cola', '_version.py')
62 exec(open(version
).read(), scope
) # pylint: disable=exec-used
63 version
= scope
['VERSION']
68 """Runs distutils.setup()"""
71 'bin/git-cola-sequence-editor',
75 if sys
.platform
== 'win32':
76 scripts
.append('contrib/win32/cola')
78 packages
= [str('cola'), str('cola.models'), str('cola.widgets')]
83 description
='The highly caffeinated git GUI',
84 long_description
='A sleek and powerful git GUI',
86 author
='David Aguilar',
87 author_email
='davvid@gmail.com',
88 url
='https://git-cola.github.io/',
93 data_files
=_data_files(),
98 """Return the list of data files"""
100 _app_path('share/git-cola/bin', '*'),
101 _app_path('share/git-cola/icons', '*.png'),
102 _app_path('share/git-cola/icons', '*.svg'),
103 _app_path('share/git-cola/icons/dark', '*.png'),
104 _app_path('share/git-cola/icons/dark', '*.svg'),
105 _app_path('share/metainfo', '*.xml'),
106 _app_path('share/applications', '*.desktop'),
107 _app_path('share/doc/git-cola', '*.rst'),
108 _app_path('share/doc/git-cola', '*.html'),
113 [_package('cola'), _package('cola.models'), _package('cola.widgets')]
117 data
.extend([_package('qtpy'), _package('qtpy._patch')])
121 _app_path(localedir
, 'git-cola.mo')
122 for localedir
in glob('share/locale/*/LC_MESSAGES')
128 def _package(package
, subdirs
=None):
129 """Collect python files for a given python "package" name"""
130 dirs
= package
.split('.')
131 app_dir
= _lib_path(*dirs
)
133 dirs
= list(subdirs
) + dirs
134 src_dir
= os
.path
.join(*dirs
)
135 return (app_dir
, glob(os
.path
.join(src_dir
, '*.py')))
138 def _lib_path(*dirs
):
139 return os
.path
.join('share', 'git-cola', 'lib', *dirs
)
142 def _app_path(dirname
, entry
):
143 """Construct (dirname, [glob-expanded-entries relative to dirname])"""
144 return (dirname
, glob(os
.path
.join(dirname
, entry
)))
147 if __name__
== '__main__':