-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsetup.py
executable file
·181 lines (152 loc) · 4.57 KB
/
setup.py
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env python
import os
import subprocess
import sys
from distutils.command.install import install as _install
from distutils.core import setup
from stat import *
INSTALLED_FILES = '.installed_files'
#stolen from ccsm
class install (_install):
def run (self):
_install.run(self)
outputs = self.get_outputs()
data = '\n'.join(outputs)
try:
f = open(INSTALLED_FILES, 'w')
except:
self.warn ('Could not write installed files list ' + INSTALLED_FILES)
return
f.write(data)
f.close()
class uninstall(_install):
def run(self):
try:
files = file(INSTALLED_FILES, 'r').readlines()
except:
self.warn('Could not read installed files list ' + INSTALLED_FILES)
return
for f in files:
print('Uninstalling ' + f.strip())
try:
os.unlink(f.strip())
except:
self.warn('Could not remove file ' + f)
os.remove(INSTALLED_FILES)
#Stolen from ccsm's setup.py
if sys.argv[1] == 'build':
qtver = '5.0'
gtkver = '3.0'
if len (sys.argv) > 2:
i = 0
for o in sys.argv:
if o.startswith('--with-qt'):
if o == '--with-qt':
if len(sys.argv) >= i:
qtver = sys.argv[i + 1]
sys.argv.remove(qtver)
elif o.startswith('--with-qt=') and len(o[10:]):
qtver = o[10:]
sys.argv.remove(o)
i += 1
i = 0
for o in sys.argv:
if o.startswith('--with-gtk'):
if o == '--with-gtk':
if len(sys.argv) >= i:
gtkver = sys.argv[i + 1]
sys.argv.remove(gtkver)
elif o.startswith('--with-gtk=') and len(o[11:]):
gtkver = o[11:]
sys.argv.remove(o)
i += 1
f = open(os.path.join ('FusionIcon/interface_qt/main.py.in'), 'rt')
data = f.read()
f.close()
data = data.replace('@qtver@', qtver.split('.')[0])
if int(qtver.split('.')[0]) >= 5:
data = data.replace('@pysidever@', "%d" % (int(qtver.split('.')[0]) - 3))
else:
data = data.replace('@pysidever@', '')
f = open(os.path.join('FusionIcon/interface_qt/main.py'), 'wt')
f.write(data)
f.close()
f = open(os.path.join ('FusionIcon/interface_gtk/main.py.in'), 'rt')
data = f.read()
f.close()
data = data.replace('@gtkver@', gtkver)
if int(gtkver.split('.')[0]) >= 3:
data = data.replace('@aaiver@', gtkver.split('.')[0])
else:
data = data.replace('@aaiver@', '')
f = open(os.path.join('FusionIcon/interface_gtk/main.py'), 'wt')
f.write(data)
f.close()
version = open('VERSION', 'r').read().strip()
packages = ['FusionIcon']
available_interfaces = {
'qt': 'FusionIcon.interface_qt',
'gtk': 'FusionIcon.interface_gtk',
}
#if 'interfaces' in os.environ:
# for interface in os.environ['interfaces'].split():
# if interface in available_interfaces:
# packages.append(available_interfaces[interface])
#else:
packages.extend(available_interfaces.values())
cmd = "intltool-merge -d -u po/ fusion-icon.desktop.in fusion-icon.desktop".split(" ")
proc = subprocess.Popen(cmd)
proc.wait()
cmd = "intltool-merge -x -u po/ fusion-icon.appdata.xml.in fusion-icon.appdata.xml".split(" ")
proc = subprocess.Popen(cmd)
proc.wait()
data_files = [
('share/icons/hicolor/22x22/apps',['images/22x22/fusion-icon.png']),
('share/icons/hicolor/24x24/apps',['images/24x24/fusion-icon.png']),
('share/icons/hicolor/32x32/apps',['images/32x32/fusion-icon.png']),
('share/icons/hicolor/48x48/apps',['images/48x48/fusion-icon.png']),
('share/icons/hicolor/scalable/apps',['images/scalable/fusion-icon.svg']),
('share/applications',['fusion-icon.desktop']),
('share/metainfo',['fusion-icon.appdata.xml']),
]
setup(
name='fusion-icon',
version=version,
description='User-friendly tray icon for launching and managing Compiz',
author='Wolfgang Ulbrich',
author_email='[email protected]',
url='https://gitlab.com/compiz/fusion-icon',
packages=packages,
scripts=['fusion-icon'],
data_files=data_files,
cmdclass={
'uninstall': uninstall,
'install': install},
)
#Stolen from ccsm's setup.py
if sys.argv[1] == 'install':
prefix = None
if len (sys.argv) > 2:
i = 0
for o in sys.argv:
if o.startswith ("--prefix"):
if o == "--prefix":
if len (sys.argv) >= i:
prefix = sys.argv[i + 1]
sys.argv.remove (prefix)
elif o.startswith ("--prefix=") and len (o[9:]):
prefix = o[9:]
sys.argv.remove (o)
break
i += 1
if not prefix:
prefix = '/usr/local'
gtk_update_icon_cache = '''gtk-update-icon-cache -f -t \
%s/share/icons/hicolor''' % prefix
root_specified = [s for s in sys.argv if s.startswith('--root')]
if not root_specified or root_specified[0] == '--root=/':
print('Updating Gtk icon cache.')
os.system(gtk_update_icon_cache)
else:
print('''*** Icon cache not updated. After install, run this:
*** %s''' % gtk_update_icon_cache)