3 # usage: use the Makefile instead of invoking this script directly.
4 from __future__
import absolute_import
, division
, unicode_literals
10 from distutils
.command
import build_scripts
11 from distutils
.core
import setup
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
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.
26 sys
.argv
.remove('--use-env-python')
29 use_env_python
= False
31 build_scripts
.first_line_re
= re
.compile('^should not match$')
33 # Disable vendoring of qtpy and friends by passing --no-vendor-libs
35 sys
.argv
.remove('--no-vendor-libs')
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')
43 exec(open(version
).read(), scope
) # pylint: disable=exec-used
44 version
= scope
['VERSION']
48 """Runs distutils.setup()"""
54 if sys
.platform
== 'win32':
55 scripts
.append('contrib/win32/cola')
57 setup(name
='git-cola',
59 description
='The highly caffeinated git GUI',
60 long_description
='A sleek and powerful git GUI',
62 author
='David Aguilar',
63 author_email
='davvid@gmail.com',
64 url
='https://git-cola.github.io/',
68 data_files
=_data_files())
72 """Return the list of data files"""
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'),
84 _package('cola.models'),
85 _package('cola.widgets'),
91 _package('qtpy._patch'),
94 data
.extend([_app_path(localedir
, 'git-cola.mo')
95 for localedir
in glob('share/locale/*/LC_MESSAGES')])
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
)
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__':