File: setup.py

package info (click to toggle)
git-cola 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,444 kB
  • ctags: 3,201
  • sloc: python: 20,539; sh: 311; makefile: 310; tcl: 48; xml: 27
file content (115 lines) | stat: -rwxr-xr-x 3,188 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python
"""git-cola installer

NOTE: This script is not typically invoked directly; use the Makefile
targets instead.

"""

from __future__ import absolute_import, division, unicode_literals

# Hacktastic hack to fix python's stupid ascii default encoding, which
# breaks inside distutils when installing from utf-8 paths.
import sys
try:
    # pylint: disable=reload-builtin
    reload(sys)
    # pylint: disable=no-member
    sys.setdefaultencoding('utf8')
except NameError:  # Python3
    pass

import os
from glob import glob
from distutils.core import setup

# Look for modules in the root
srcdir = os.path.dirname(os.path.abspath(__file__))

from extras import cmdclass

here = os.path.dirname(__file__)
version = os.path.join(here, 'cola', '_version.py')
scope = {}
exec(open(version).read(), scope)  # pylint: disable=exec-used
version = scope['VERSION']


def main():
    """Runs distutils.setup()"""
    vendor_libs = should_vendor_libs()

    scripts = [
        'bin/git-cola',
        'bin/git-dag',
    ]

    if sys.platform == 'win32':
        scripts.append('contrib/win32/cola')

    setup(name='git-cola',
          version=version,
          description='The highly caffeinated git GUI',
          long_description='A sleek and powerful git GUI',
          license='GPLv2',
          author='David Aguilar',
          author_email='davvid@gmail.com',
          url='https://git-cola.github.io/',
          scripts=scripts,
          cmdclass=cmdclass,
          platforms='any',
          data_files=_data_files(vendor_libs))


def should_vendor_libs():
    """Return True if we should include vendored libraries"""
    vendor_libs = not os.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
    if '--no-vendor-libs' in sys.argv:
        sys.argv.remove('--no-vendor-libs')
        vendor_libs = False
    return vendor_libs


def _data_files(vendor_libs):
    """Return the list of data files"""
    data = [
        _app_path('share/git-cola/bin', '*'),
        _app_path('share/git-cola/icons', '*.png'),
        _app_path('share/git-cola/icons', '*.svg'),
        _app_path('share/appdata', '*.xml'),
        _app_path('share/applications', '*.desktop'),
        _app_path('share/doc/git-cola', '*.rst'),
        _app_path('share/doc/git-cola', '*.html'),
        _package('cola'),
        _package('cola.models'),
        _package('cola.widgets'),
    ]

    if vendor_libs:
        data.extend([
            _package('qtpy'),
            _package('qtpy._patch'),
        ])

    data.extend([_app_path(localedir, 'git-cola.mo')
                 for localedir in glob('share/locale/*/LC_MESSAGES')])
    return data


def _package(package, subdirs=None):
    """Collect python files for a given python "package" name"""
    dirs = package.split('.')
    app_dir = os.path.join('share', 'git-cola', 'lib', *dirs)
    if subdirs:
        dirs = list(subdirs) + dirs
    src_dir = os.path.join(*dirs)
    return (app_dir, glob(os.path.join(src_dir, '*.py')))


def _app_path(dirname, entry):
    """Construct (dirname, [glob-expanded-entries relative to dirname])"""
    return (dirname, glob(os.path.join(dirname, entry)))


if __name__ == '__main__':
    main()