24
by Umang Varma
Added .desktop and setup.py files. |
1 |
#!/usr/bin/python3
|
2 |
# -*- coding: utf-8 -*-
|
|
3 |
#
|
|
113
by Umang Varma
Release 0.4.5 |
4 |
# Copyright © 2012-2015 Umang Varma <umang.me@gmail.com>
|
24
by Umang Varma
Added .desktop and setup.py files. |
5 |
#
|
6 |
# This file is part of indicator-stickynotes.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
# more details.
|
|
17 |
#
|
|
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/>.
|
|
20 |
||
21 |
from distutils.core import setup |
|
37
by Umang Varma
Translation build and install in setup.py |
22 |
from distutils.cmd import Command |
23 |
import distutils.command.build, distutils.command.install_data, \ |
|
24 |
distutils.command.clean |
|
25 |
||
26 |
from subprocess import call |
|
27 |
||
28 |
import glob |
|
29 |
import os |
|
30 |
import sys |
|
31 |
import shutil |
|
32 |
||
33 |
sys.dont_write_bytecode = True |
|
34 |
from stickynotes.info import PO_DIR, MO_DIR, LOCALE_DOMAIN |
|
35 |
sys.dont_write_bytecode = False |
|
36 |
||
37 |
class BuildPo(Command): |
|
38 |
"""Builds translation files
|
|
39 |
|
|
40 |
This is useful for testing translations that haven't been installed"""
|
|
41 |
user_options = [] |
|
42 |
def initialize_options(self): |
|
43 |
pass
|
|
44 |
def finalize_options(self): |
|
45 |
pass
|
|
46 |
def run(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) |
|
53 |
try: |
|
54 |
ret = call(["msgfmt", "-o", dest, file]) |
|
55 |
except OSError: |
|
56 |
raise Exception("Error: Unable to run msgfmt") |
|
57 |
if ret: |
|
58 |
raise Exception("Error: msgfmt returned error code {0}" \ |
|
59 |
.format(ret)) |
|
60 |
||
61 |
class Build(distutils.command.build.build): |
|
62 |
# build should depend on build_po
|
|
63 |
sub_commands = distutils.command.build.build.sub_commands + \ |
|
64 |
[('build_po', None)] |
|
65 |
||
66 |
class Clean(distutils.command.clean.clean): |
|
67 |
def run(self): |
|
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) |
|
71 |
return super().run() |
|
72 |
||
73 |
class InstallData(distutils.command.install_data.install_data): |
|
74 |
"""Find icon and translation files before continuing install process"""
|
|
75 |
||
76 |
def run(self): |
|
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]) |
|
80 |
return super().run() |
|
81 |
||
82 |
def main(): |
|
83 |
# Default data files
|
|
55
by Umang Varma
Updated setup.py for version 0.3 |
84 |
data_files = [('', ('COPYING', 'style.css', 'StickyNotes.glade', |
82
by Umang Varma
Added SettingsCategory.glade to data files |
85 |
'style_global.css', 'GlobalDialogs.glade', |
86 |
'SettingsCategory.glade')), |
|
37
by Umang Varma
Translation build and install in setup.py |
87 |
('/usr/share/applications', ('indicator-stickynotes.desktop',)), |
88 |
('Icons', glob.glob("Icons/*.png"))] |
|
89 |
# Icon themes
|
|
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]) |
|
96 |
||
97 |
setup(name='indicator-stickynotes', |
|
118
by Umang Varma
Release 0.4.6 |
98 |
version='0.4.6', |
99 |
description='Sticky Notes Indicator', |
|
37
by Umang Varma
Translation build and install in setup.py |
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, |
|
55
by Umang Varma
Updated setup.py for version 0.3 |
107 |
'build_po': BuildPo, 'clean':Clean}, |
108 |
long_description="Indicator Stickynotes helps you jot down " |
|
109 |
"thoughts, write lists, and make reminders quickly.") |
|
37
by Umang Varma
Translation build and install in setup.py |
110 |
|
111 |
if __name__ == "__main__": |
|
112 |
main() |