2
# -*- coding: utf-8 -*-
4
# Copyright © 2012-2015 Umang Varma <umang.me@gmail.com>
6
# This file is part of indicator-stickynotes.
8
# indicator-stickynotes is free software: you can redistribute it and/or
9
# modify it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or (at your
11
# option) any later version.
13
# indicator-stickynotes is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18
# You should have received a copy of the GNU General Public License along with
19
# indicator-stickynotes. If not, see <http://www.gnu.org/licenses/>.
21
from distutils.core import setup
22
from distutils.cmd import Command
23
import distutils.command.build, distutils.command.install_data, \
24
distutils.command.clean
26
from subprocess import call
33
sys.dont_write_bytecode = True
34
from stickynotes.info import PO_DIR, MO_DIR, LOCALE_DOMAIN
35
sys.dont_write_bytecode = False
37
class BuildPo(Command):
38
"""Builds translation files
40
This is useful for testing translations that haven't been installed"""
42
def initialize_options(self):
44
def finalize_options(self):
47
"""Compiles .po files in PO_DIR to .mo files in MO_DIR"""
48
for file in glob.glob(os.path.join(PO_DIR, "*.po")):
49
locale = os.path.splitext(os.path.basename(file))[0]
50
dest = os.path.join(MO_DIR, locale, "LC_MESSAGES",
51
LOCALE_DOMAIN + ".mo")
52
os.makedirs(os.path.dirname(dest), exist_ok=True)
54
ret = call(["msgfmt", "-o", dest, file])
56
raise Exception("Error: Unable to run msgfmt")
58
raise Exception("Error: msgfmt returned error code {0}" \
61
class Build(distutils.command.build.build):
62
# build should depend on build_po
63
sub_commands = distutils.command.build.build.sub_commands + \
66
class Clean(distutils.command.clean.clean):
68
# delete MO_DIR files before cleaning everything else
69
print("Deleting {0}/ and contents".format(MO_DIR))
70
shutil.rmtree(MO_DIR, ignore_errors=True)
73
class InstallData(distutils.command.install_data.install_data):
74
"""Find icon and translation files before continuing install process"""
77
self.data_files.extend([(os.path.join("/usr/share/", dir),
78
[os.path.join(dir, file) for file in files]) for dir, subdirs,
79
files in os.walk("locale") if files])
84
data_files = [('', ('COPYING', 'style.css', 'StickyNotes.glade',
85
'style_global.css', 'GlobalDialogs.glade',
86
'SettingsCategory.glade')),
87
('/usr/share/applications', ('indicator-stickynotes.desktop',)),
88
('Icons', glob.glob("Icons/*.png"))]
90
icon_themes = ["hicolor", "ubuntu-mono-dark", "ubuntu-mono-light"]
91
for theme in icon_themes:
92
data_files.extend([(os.path.join("/usr/share/icons/", theme,
93
os.path.relpath(dir, "Icons/" + theme)), [os.path.join(
94
dir, file) for file in files])
95
for dir, subdirs, files in os.walk("Icons/" + theme) if files])
97
setup(name='indicator-stickynotes',
99
description='Sticky Notes Indicator',
100
author='Umang Varma',
101
author_email='umang.me@gmail.com',
102
url='https://www.launchpad.net/indicator-stickynotes/',
103
packages=['stickynotes',],
104
scripts=['indicator-stickynotes.py',],
105
data_files=data_files,
106
cmdclass={'build': Build, 'install_data': InstallData,
107
'build_po': BuildPo, 'clean':Clean},
108
long_description="Indicator Stickynotes helps you jot down "
109
"thoughts, write lists, and make reminders quickly.")
111
if __name__ == "__main__":