Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
151 lines (134 loc) · 5.78 KB
/
Copy pathsetup.py
File metadata and controls
151 lines (134 loc) · 5.78 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
148
149
150
151
#!/usr/bin/python
#
# INFO: The setup-script for the screenlets
# (c) 2008 Rico Pfaus (RYX), Helder Fraga (Whise), and Natan Yellin (Aantn)
# (c) 2010-2011 Guido Tabbernuk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from distutils.core import setup
import distutils.sysconfig
import os
import sys
# import screenlets to get package constants
#sys.path.insert(0, 'src/')
#import lib # screenlets-package called 'lib' here because of the dir-names
VERSION = open("VERSION").readline().strip()
def filter_filename_callback(filename):
"""Called by make_file_list to determine which files to add/install
to the package and which files are to be ignored."""
# skip temp-files
if filename[-1] == '~':
return False
return True
def scan_dir_list(path):
"""makes a list of all subdirectories of a path"""
out = []
plen = len(path) + 1
files = os.listdir(path)
for f in files:
full = path + '/' + f
if (os.path.isdir(full)):
out.append(full)
out.extend(scan_dir_list(full))
return out
def make_file_list(dirlist, install_path, strip=''):
"""Takes a list with dirnames and creates a list suitable for the
data_files-attribute for the setup-function that includes all files
within the dir. The string defined by strip will be replaced from
within the directory names. TODO: the strip-arg is not very secure
and could cause errors ... fix that!!!!!!!!!! """
data_files = []
for d in dirlist:
dlst = []
files = os.listdir(d)
for f in files:
full = d +'/' + f
if os.path.isfile(full):
if filter_filename_callback(f):
dlst.append(full)
data_files.append((install_path + '/' + d.replace(strip, ''), dlst))
return data_files
# ---------------------------------------------------------------
# Create various lists of files that will be passed to setup()
# ---------------------------------------------------------------
# Create a list of scripts that will be installed into PREFIX/bin/
scripts_list = ['src/bin/screenletsd',
'src/bin/screenlets',
'src/bin/screenlets-manager',
'src/bin/screenlets-daemon',
'src/bin/screenlets-packager',
'src/bin/screenlets-debianizer']
files_list = []
# Empty screenlets dir
files_list.insert(0, ('share/screenlets', []))
# Install the manager's files into PREFIX/share/screenlets-manager
files_list.insert(0, ('share/screenlets-manager',
['src/share/screenlets-manager/screenlets-manager.py',
'src/share/screenlets-manager/screenlets-daemon.py',
'src/share/screenlets-manager/screenlets-packager.py',
'src/share/screenlets-manager/screenlets-debianizer.py',
'src/share/screenlets-manager/prefs.js',
'src/share/screenlets-manager/noimage.svg',
'src/share/screenlets-manager/KarambaScreenlet.py',
'src/share/screenlets-manager/widget.png',
'src/share/screenlets-manager/WidgetScreenlet.py',
'src/share/screenlets-manager/webframe.png',
'src/share/screenlets-manager/WebframeScreenlet.py',
'src/share/screenlets-manager/karamba.png']))
# Install desktop files and icons
files_list.insert(0, ('share/applications', ['desktop-menu/screenlets-manager.desktop']))
files_list.insert(0, ('share/icons/hicolor/scalable/apps', ['desktop-menu/screenlets.svg']))
files_list.insert(0, ('share/icons/hicolor/scalable/apps', ['desktop-menu/screenlets-tray.svg']))
files_list.insert(0, ('share/icons/ubuntu-mono-dark/apps/24', ['desktop-menu/mono-dark/screenlets-tray.svg']))
files_list.insert(0, ('share/icons/ubuntu-mono-light/apps/24', ['desktop-menu/mono-light/screenlets-tray.svg']))
# Install translation files
buildcmd = "msgfmt -o build/locale/%s/LC_MESSAGES/%s.mo %s/%s.po"
mopath = "build/locale/%s/LC_MESSAGES/%s.mo"
destpath = "share/locale/%s/LC_MESSAGES"
for name in os.listdir ("screenlets"):
if name.endswith('.po'):
dname = name.split('.')[0]
name = "screenlets"
if sys.argv[1] == "build" or sys.argv[1] == "install":
print 'Creating language Binary for : ' + name
if not os.path.isdir ("build/locale/%s/LC_MESSAGES" % dname):
os.makedirs ("build/locale/%s/LC_MESSAGES" % dname)
os.system (buildcmd % (dname, name, name, dname))
files_list.append ((destpath % dname, [mopath % (dname,name.replace('-'+dname,''))]))
for name in os.listdir ("screenlets-manager"):
if name.endswith('.po'):
dname = name.split('.')[0]
name = "screenlets-manager"
if sys.argv[1] == "build" or sys.argv[1] == "install":
print 'Creating language Binary for : ' + name
if not os.path.isdir ("build/locale/%s/LC_MESSAGES" % dname):
os.makedirs ("build/locale/%s/LC_MESSAGES" % dname)
os.system (buildcmd % (dname, name, name, dname))
files_list.append ((destpath % dname, [mopath % (dname,name.replace('-'+dname,''))]))
PACKAGES = ['screenlets','screenlets.plugins','screenlets.options']
# ----------------------------
# Call setup()
# ----------------------------
setup(name='screenlets',
version = VERSION,
description = 'A widget framework for Linux',
url = 'http://www.screenlets.org',
author = 'Whise (Helder Fraga) <helder.fraga@hotmail.com>, RYX (Rico Pfaus) <ryx@ryxperience.com>, Sorcerer (Hendrik Kaju), Natan Yellin (Aantn) <aantny@gmail.com>, Guido Tabbernuk <boamaod@gmail.com>',
author_email = 'boamaod@gmail.com',
license = 'GPL v3',
packages = PACKAGES,
package_dir = {'screenlets': 'src/lib'},
data_files = files_list,
scripts = scripts_list
)