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 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
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.
27 sys
.argv
.remove('--use-env-python')
30 use_env_python
= False
32 build_scripts
.first_line_re
= re
.compile(r
'^should not match$')
34 # Disable vendoring of qtpy and friends by passing --no-vendor-libs
36 sys
.argv
.remove('--no-vendor-libs')
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')
44 exec(open(version
).read(), scope
) # pylint: disable=exec-used
45 version
= scope
['VERSION']
49 """Runs distutils.setup()"""
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',
67 description
='The highly caffeinated git GUI',
68 long_description
='A sleek and powerful git GUI',
70 author
='David Aguilar',
71 author_email
='davvid@gmail.com',
72 url
='https://git-cola.github.io/',
76 data_files
=_data_files())
80 """Return the list of data files"""
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'),
92 _package('cola.models'),
93 _package('cola.widgets'),
99 _package('qtpy._patch'),
102 data
.extend([_app_path(localedir
, 'git-cola.mo')
103 for localedir
in glob('share/locale/*/LC_MESSAGES')])
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
)
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__':