forked from chuchiperriman/cloud-services-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·150 lines (123 loc) · 4.94 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from distutils.core import setup
from glob import glob
from distutils.command.install_data import install_data
from distutils.command.build import build
from distutils.dep_util import newer
from distutils.log import warn, info, error, fatal
import os
import sys
import subprocess
from imp import load_module, find_module
const = load_module("const", *find_module("const",["src/cloudsn"]))
#check dependencies
DEPENDENCIES = ['gtk', 'pynotify', 'xdg', 'gconf', 'dbus']
DEP_OPTIONALS = ['indicate']
err_deps = []
for dep in DEPENDENCIES:
try:
__import__(dep)
except ImportError:
err_deps += [dep]
if len(err_deps) > 0:
print 'Dependencies not found: '
for dep in err_deps:
print '\t', dep
sys.exit(1)
err_opts = []
for dep in DEP_OPTIONALS:
try:
__import__(dep)
except ImportError:
err_opts += [dep]
if len(err_deps) > 0:
print 'Optional dependencies not founds: '
for dep in err_deps:
print '\t', dep
os.chdir(os.path.abspath(os.path.dirname(__file__)))
PO_DIR = 'po'
MO_DIR = os.path.join('build', 'mo')
DATA_FILES = [("share/cloudsn",
["README", "INSTALL", "AUTHORS", "COPYING", "NEWS", "data/cloudsn.desktop"])]
#Icons and UI
DATA_FILES += [("share/cloudsn", glob('data/*.png'))]
DATA_FILES += [("share/cloudsn", glob('data/*.ui'))]
DATA_FILES += [("share/cloudsn", glob('data/*.ogg'))]
#desktop
DATA_FILES += [('share/applications', ['data/cloudsn.desktop'])]
DATA_FILES += [('share/icons/hicolor/scalable/apps', ['data/cloudsn.svg'])]
DATA_FILES += [('share/pixmaps', ['data/cloudsn.svg'])]
DATA_FILES += [('share/icons/hicolor/24x24/apps', ['data/cloudsn.png'])]
class BuildData(build):
def run (self):
build.run (self)
#if self.distribution.without_gettext:
# return
for po in glob (os.path.join (PO_DIR, '*.po')):
lang = os.path.basename(po[:-3])
mo = os.path.join(MO_DIR, lang, 'cloudsn.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)
TOP_BUILDDIR='.'
INTLTOOL_MERGE='intltool-merge'
#desktop_in='data/terminator.desktop.in'
#desktop_data='data/terminator.desktop'
#os.system ("C_ALL=C " + INTLTOOL_MERGE + " -d -u -c " + TOP_BUILDDIR +
# "/po/.intltool-merge-cache " + TOP_BUILDDIR + "/po " +
# desktop_in + " " + desktop_data)
class InstallData(install_data):
def run (self):
self.data_files.extend (self._find_mo_files ())
install_data.run (self)
#if not self.distribution.without_icon_cache:
# self._update_icon_cache ()
for path in self.get_outputs():
if path.endswith ('share/applications/cloudsn.desktop'):
#Install the indicator file
try:
f = open ('/usr/share/indicators/messages/applications/cloudsn', 'w')
f.write (path + '\n')
f.close()
except Exception:
warn("Cannot create the indicator file")
# We should do this on uninstall too
def _update_icon_cache(self):
info("running gtk-update-icon-cache")
try:
subprocess.call(["gtk-update-icon-cache", "-q", "-f", "-t", os.path.join(self.install_dir, "share/icons/hicolor")])
except Exception, e:
warn("updating the GTK icon cache failed: %s" % str(e))
def _find_mo_files (self):
data_files = []
if True: #if not self.distribution.without_gettext:
for mo in glob (os.path.join (MO_DIR, '*', 'cloudsn.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=const.APP_NAME,
version=const.APP_VERSION,
description='Python Distribution Utilities',
author=r'Jesús Barbero Rodríguez',
author_email='chuchiperriman@gmail.com',
url='http://github.com/chuchiperriman',
package_dir = {'' : 'src'},
packages=['cloudsn', 'cloudsn.core', 'cloudsn.ui', 'cloudsn.ui.indicators',
'cloudsn.providers', 'cloudsn.providers.tweepy', 'cloudsn.core.keyrings'],
data_files = DATA_FILES,
scripts=['cloudsn'],
cmdclass={'build': BuildData, 'install_data': InstallData}
)