forked from fontanon/udev-discover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
133 lines (108 loc) · 4.76 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os, platform
import glob
import subprocess
from distutils.core import setup
from distutils.command.build import build
from distutils.command.install_data import install_data
from distutils.log import warn, info, error, fatal
from distutils.dep_util import newer
PO_DIR = 'po'
MO_DIR = os.path.join('build', 'mo')
class BuildData(build):
user_options = [
('prefix=', None, "installation prefix"),
]
def initialize_options(self):
build.initialize_options(self)
self.prefix = None
def finalize_options(self):
build.finalize_options(self)
if not self.prefix:
install = self.distribution.get_command_obj('install', False)
if install:
self.prefix = install.prefix
else:
self.prefix = sys.prefix
def run (self):
# Gen .in files with @PREFIX@ replaced
for filename in ['udev-discover']:
infile = open(filename + '.in', 'r')
data = infile.read().replace('@PREFIX@', self.prefix)
infile.close()
outfile = open(filename, 'w')
outfile.write(data)
outfile.close()
build.run (self)
for po in glob.glob (os.path.join (PO_DIR, '*.po')):
lang = os.path.basename(po[:-3])
mo = os.path.join(MO_DIR, lang, 'udevdiscover.mo')
directory = os.path.dirname(mo)
if not os.path.exists(directory):
info('creating %s' % directory)
os.makedirs(directory)
if newer(po, mo):
info('compiling %s -> %s' % (po, mo))
try:
rc = subprocess.call(['msgfmt', '-o', mo, po])
if rc != 0:
raise Warning, "msgfmt returned %d" % rc
except Exception, e:
error("Building gettext files failed. Try setup.py \
--without-gettext [build|install]")
error("Error: %s" % str(e))
sys.exit(1)
class InstallData(install_data):
def run (self):
self.data_files.extend (self._find_mo_files ())
install_data.run (self)
def _find_mo_files (self):
data_files = []
for mo in glob.glob (os.path.join (MO_DIR, '*', 'udevdiscover.mo')):
lang = os.path.basename(os.path.dirname(mo))
dest = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
data_files.append((dest, [mo]))
return data_files
setup(
name='udev-discover',
version='0.2',
description='A GUI tool for exploring the present devices on the system',
author='J. Félix Ontañón',
author_email='fontanon@emergya.es',
url='http://gitorious.org/udev-discover/udev-discover',
classifiers=[
'Development Status :: 0.2 - Beta',
'Environment :: Desktop Environment',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: POSIX',
'Programming Language :: Python',
'Topic :: Utilities'
],
keywords = ['python', 'udev', 'gnome'],
packages = ['udevdiscover', 'udevdiscover.device',
'udevdiscover.device.block', 'udevdiscover.device.input'],
package_dir = {'udevdiscover': 'udevdiscover',
'udevdiscover.device': 'udevdiscover/device',
'udevdiscover.device.block': 'udevdiscover/device/block',
'udevdiscover.device.input': 'udevdiscover/device/input',
},
scripts = ['udev-discover'],
cmdclass={'build': BuildData, 'install_data': InstallData},
data_files = [
('share/udev-discover', ['data/udev-discover.ui']),
('share/udev-discover', ['data/udev-discover.svg']),
('share/pixmaps', ['data/udev-discover.svg']),
('/etc/gconf/schemas', ['data/udev-discover.schemas']),
('share/applications', ['data/udev-discover.desktop']),
# You may need to call gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
# after installing icons
('share/icons/hicolor/16x16/devices', glob.glob('data/icons/16x16/devices/*')),
('share/icons/hicolor/22x22/devices', glob.glob('data/icons/22x22/devices/*')),
('share/icons/hicolor/24x24/devices', glob.glob('data/icons/24x24/devices/*')),
('share/icons/hicolor/48x48/devices', glob.glob('data/icons/48x48/devices/*')),
('share/icons/hicolor/scalable/devices', glob.glob('data/icons/scalable/devices/*')),
('share/icons/hicolor/scalable/apps', ['data/udev-discover.svg']),
],
)