-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
184 lines (150 loc) · 5.46 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/env python
#
# Copyright (C) 2005-2010 TUBITAK/UEKAE
#
# 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 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
import os
import sys
import glob
import shutil
import sipconfig
from distutils.core import setup, Extension
from distutils.sysconfig import get_python_lib
from distutils.cmd import Command
from distutils.command.build import build
from distutils.command.clean import clean
from distutils.command.install import install
from distutils.spawn import find_executable # , spawn
I18N_DOMAIN = "yali"
I18N_LANGUAGES = ["tr", "en", "nl", "it", "fr", "de", "pt_BR", "es",
"pl", "ca", "sv", "hu", "ru", "hr"]
# WARNING: update_messages and release_messages run with python3
def update_messages():
files = glob.glob("build/lib.linux-x86_64-2.7/yali/**/*.py",
recursive=True)
# print(files)
for lng in I18N_LANGUAGES:
print(lng)
os.system("pylupdate5 -translate-function _ {files} -ts lang/{lang}.ts\
".format(files=" ".join(files), lang=lng))
def release_messages():
ts_files = glob.glob1("lang", "*.ts")
ts_files = "lang/" + " lang/".join(ts_files)
os.system("lrelease {}".format(ts_files))
def qt_ui_files():
ui_files = "yali/gui/Ui/*.ui"
return glob.glob(ui_files)
def py_file_name(ui_file):
return os.path.splitext(ui_file)[0] + '.py'
class YaliBuild(build):
def changeQRCPath(self, ui_file):
py_file = py_file_name(ui_file)
lines = open(py_file, "r").readlines()
replaced = open(py_file, "w")
for line in lines:
if line.find("data_rc") != -1:
continue
replaced.write(line)
def compileUI(self, ui_file):
pyqt_configuration = sipconfig.Configuration()
pyuic_exe = find_executable(
'py2uic5', pyqt_configuration.default_bin_dir)
if not pyuic_exe:
pyuic_exe = find_executable('py2uic5')
cmd = [pyuic_exe, ui_file, '-o']
cmd.append(py_file_name(ui_file))
# cmd.append("-g \"yali\"")
os.system(' '.join(cmd))
def run(self):
release_messages()
for ui_file in qt_ui_files():
print(ui_file)
self.compileUI(ui_file)
self.changeQRCPath(ui_file)
build.run(self)
class YaliClean(clean):
def run(self):
clean.run(self)
for ui_file in qt_ui_files():
ui_file = py_file_name(ui_file)
if os.path.exists(ui_file):
os.unlink(ui_file)
if os.path.exists("build"):
shutil.rmtree("build")
class YaliUninstall(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
yali_dir = os.path.join(get_python_lib(), "yali")
if os.path.exists(yali_dir):
print("removing: ", yali_dir)
shutil.rmtree(yali_dir)
conf_dir = "/etc/yali"
if os.path.exists(conf_dir):
print("removing: ", conf_dir)
shutil.rmtree(conf_dir)
if os.path.exists("/usr/share/applications/yali.desktop"):
print("removing: rest of installation")
os.unlink("/usr/share/applications/yali.desktop")
os.unlink("/usr/bin/yali-bin")
os.unlink("/usr/bin/start-yali")
os.unlink("/usr/bin/bindYali")
os.unlink("/lib/udev/rules.d/70-yali.rules")
class I18nInstall(install):
def run(self):
install.run(self)
for lang in I18N_LANGUAGES:
print("Installing '%s' translations..." % lang)
os.popen("msgfmt po/%s.po -o po/%s.mo" % (lang, lang))
if not self.root:
self.root = "/"
destpath = os.path.join(
self.root, "usr/share/locale/%s/LC_MESSAGES" % lang)
try:
os.makedirs(destpath)
except Exception:
pass
shutil.copy("po/%s.mo" % lang,
os.path.join(destpath, "%s.mo" % I18N_DOMAIN))
if "update_messages" in sys.argv:
update_messages()
sys.exit(0)
elif "release_messages" in sys.argv:
release_messages()
sys.exit(0)
setup(
name="yali",
version="3.0.2",
description="YALI (Yet Another Linux Installer)",
long_description="Pisi Linux System Installer.",
license="Latest GNU GPL version",
author="Pisi Linux Developers",
author_email="[email protected]",
url="https://github.com/pisilinux/project",
packages=['yali', 'yali.gui', 'yali.gui.Ui', 'yali.storage',
'yali.storage.devices', 'yali.storage.formats',
'yali.storage.library'],
data_files=[('/etc/yali', glob.glob("conf/*")),
('/lib/udev/rules.d', ["70-yali.rules"]),
('/usr/share/applications', ["yali.desktop"]),
('/usr/share/yali/lang', glob.glob("lang/*.qm"))],
scripts=['yali-bin', 'start-yali', 'bindYali'],
ext_modules=[Extension('yali._sysutils',
sources=['yali/_sysutils.c'],
libraries=["ext2fs"],
extra_compile_args=['-Wall'])],
cmdclass={
'build': YaliBuild,
'clean': YaliClean,
'install': I18nInstall,
'uninstall': YaliUninstall
}
)