forked from git-cola/git-cola
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·147 lines (123 loc) · 4.31 KB
/
setup.py
File metadata and controls
executable file
·147 lines (123 loc) · 4.31 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python
# usage: use the Makefile instead of invoking this script directly.
# pylint: disable=import-error,no-name-in-module
from __future__ import absolute_import, division, print_function, unicode_literals
from glob import glob
from distutils.command import build_scripts
from distutils.core import setup
import os
import re
import sys
sys.path.insert(1, os.path.dirname(__file__))
from extras import cmdclass
# Hack: prevent python2's ascii default encoding from breaking inside
# distutils when installing from utf-8 paths.
if sys.version_info[0] < 3:
# pylint: disable=reload-builtin,undefined-variable
reload(sys) # noqa
# pylint: disable=no-member
sys.setdefaultencoding('utf-8')
# Prevent distutils from changing "#!/usr/bin/env python" when
# --use-env-python is specified.
try:
sys.argv.remove('--use-env-python')
use_env_python = True
except ValueError:
use_env_python = False
if use_env_python:
if sys.version_info[0] < 3:
# Python2 accepts the r'' unicode literal.
pattern = re.compile(r'^should not match$')
else:
# Python3 reads files as bytes and requires that the regex pattern is
# specified as bytes.
pattern = re.compile(b'^should not match$')
build_scripts.first_line_re = pattern
# Disable installation of the private cola package by passing --no-private-libs or
# by setting GIT_COLA_NO_PRIVATE_LIBS=1 in th environment.
try:
sys.argv.remove('--no-private-libs')
private_libs = False
except ValueError:
private_libs = not os.getenv('GIT_COLA_NO_PRIVATE_LIBS', '')
# Disable vendoring of qtpy and friends by passing --no-vendor-libs to setup.py or
# by setting GIT_COLA_NO_VENDOR_LIBS=1 in the environment.
try:
sys.argv.remove('--no-vendor-libs')
vendor_libs = False
except ValueError:
vendor_libs = not os.getenv('GIT_COLA_NO_VENDOR_LIBS', '')
# fmt: off
here = os.path.dirname(__file__)
version = os.path.join(here, 'cola', '_version.py')
scope = {}
# flake8: noqa
exec(open(version).read(), scope) # pylint: disable=exec-used
version = scope['VERSION']
# fmt: on
def main():
"""Runs distutils.setup()"""
scripts = [
'bin/git-cola',
'bin/git-cola-sequence-editor',
'bin/git-dag',
]
if sys.platform == 'win32':
scripts.append('contrib/win32/cola')
packages = [str('cola'), str('cola.models'), str('cola.widgets')]
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,
packages=packages,
platforms='any',
data_files=_data_files(),
)
def _data_files():
"""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/git-cola/icons/dark', '*.png'),
_app_path('share/git-cola/icons/dark', '*.svg'),
_app_path('share/metainfo', '*.xml'),
_app_path('share/applications', '*.desktop'),
_app_path('share/doc/git-cola', '*.rst'),
_app_path('share/doc/git-cola', '*.html'),
]
if private_libs:
data.extend(
[_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 = _lib_path(*dirs)
if subdirs:
dirs = list(subdirs) + dirs
src_dir = os.path.join(*dirs)
return (app_dir, glob(os.path.join(src_dir, '*.py')))
def _lib_path(*dirs):
return os.path.join('share', 'git-cola', 'lib', *dirs)
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()