4 NOTE: This script is not typically invoked directly; use the Makefile
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.
15 # pylint: disable=reload-builtin
17 # pylint: disable=no-member
18 sys
.setdefaultencoding('utf-8')
19 except NameError: # Python3
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')
34 exec(open(version
).read(), scope
) # pylint: disable=exec-used
35 version
= scope
['VERSION']
39 """Runs distutils.setup()"""
40 vendor_libs
= should_vendor_libs()
47 if sys
.platform
== 'win32':
48 scripts
.append('contrib/win32/cola')
50 setup(name
='git-cola',
52 description
='The highly caffeinated git GUI',
53 long_description
='A sleek and powerful git GUI',
55 author
='David Aguilar',
56 author_email
='davvid@gmail.com',
57 url
='https://git-cola.github.io/',
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')
73 def _data_files(vendor_libs
):
74 """Return the list of data files"""
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'),
86 _package('cola.models'),
87 _package('cola.widgets'),
93 _package('qtpy._patch'),
96 data
.extend([_app_path(localedir
, 'git-cola.mo')
97 for localedir
in glob('share/locale/*/LC_MESSAGES')])
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
)
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__':