1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +01:00

Re-organize setup.py, provide a --no-install-i18n

This commit is contained in:
David Paleino
2012-05-10 00:53:44 +02:00
parent c212552e24
commit ab8ecb6ba8
2 changed files with 159 additions and 139 deletions

View File

@@ -78,6 +78,7 @@ log_perms = '%LOGPERMS%'
no_install_pmutils = %NO_INSTALL_PMUTILS%
no_install_init = %NO_INSTALL_INIT%
no_install_man = %NO_INSTALL_MAN%
no_install_i18n = %NO_INSTALL_I18N%
no_install_i18n_man = %NO_INSTALL_I18N_MAN%
no_install_kde = %NO_INSTALL_KDE%
no_install_acpi = %NO_INSTALL_ACPI%

221
setup.py
View File

@@ -19,6 +19,8 @@
from distutils.core import setup, Command
from distutils.extension import Extension
from distutils.command.build import build as _build
from distutils.command.install import install as _install
import os
import sys
import shutil
@@ -32,6 +34,12 @@ VERSION_NUM = '1.7.2.4'
REVISION_NUM = 'unknown'
CURSES_REVNO = 'uimod'
data = []
# path to the file to put in empty directories
# fixes https://bugs.launchpad.net/wicd/+bug/503028
empty_file = 'other/.empty_on_purpose'
# change to the directory setup.py is contained in
os.chdir(os.path.abspath(os.path.split(__file__)[0]))
@@ -47,6 +55,12 @@ except Exception, e:
print 'failed to find revision number:'
print e
class build(_build):
sub_commands = _build.sub_commands + [('compile_translations', None)]
def run(self):
_build.run(self)
class configure(Command):
description = "configure the paths that Wicd will be installed to"
@@ -102,6 +116,7 @@ class configure(Command):
# Configure switches
('no-install-init', None, "do not install the init file"),
('no-install-man', None, 'do not install the man files'),
('no-install-i18n', None, 'do not install translation files'),
('no-install-i18n-man', None, 'do not install the translated man files'),
('no-install-kde', None, 'do not install the kde autostart file'),
('no-install-acpi', None, 'do not install the suspend.d and resume.d acpi scripts'),
@@ -149,6 +164,7 @@ class configure(Command):
self.no_install_init = False
self.no_install_man = False
self.no_install_i18n = False
self.no_install_i18n_man = False
self.no_install_kde = False
self.no_install_acpi = False
@@ -366,8 +382,6 @@ class configure(Command):
item_in.close()
shutil.copymode(original_name, final_name)
trans = compile_translations(self.distribution)
trans.run()
class clear_generated(Command):
description = 'clears out files generated by configure'
@@ -398,109 +412,19 @@ class clear_generated(Command):
shutil.rmtree('translations/')
os.makedirs('translations/')
class test(Command):
description = "run Wicd's unit tests"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
class install(_install):
def run(self):
print "importing tests"
import tests
print 'running tests'
tests.run_tests()
class update_message_catalog(Command):
description = "update wicd.pot with new strings"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('pybabel extract . -o po/wicd.pot --sort-output')
os.system('xgettext -L glade data/wicd.ui -j -o po/wicd.pot')
class update_translations(Command):
description = "update po-files with new strings from wicd.pot"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
for pofile in glob('po/*.po'):
lang = pofile.replace('po/', '').replace('.po', '')
os.system('pybabel update -N -o %s -i po/wicd.pot -D wicd -l %s' % (pofile, lang))
class compile_translations(Command):
description = 'compile po-files to binary mo'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
if os.path.exists('translations'):
shutil.rmtree('translations/')
os.makedirs('translations')
for pofile in glob('po/*.po'):
lang = pofile.replace('po/', '').replace('.po', '')
os.makedirs('translations/' + lang + '/LC_MESSAGES/')
os.system('pybabel compile -D wicd -i %s -l %s -d translations/' % (pofile, lang))
class uninstall(Command):
description = "remove Wicd using uninstall.sh and install.log"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system("./uninstall.sh")
try:
import wpath
except ImportError:
print '''Error importing wpath.py. You can safely ignore this
message. It is probably because you haven't run python setup.py
configure yet or you are running it for the first time.'''
data = []
py_modules = ['wicd.networking','wicd.misc','wicd.wnettools',
'wicd.wpath','wicd.dbusmanager',
'wicd.logfile','wicd.backend','wicd.configmanager',
'wicd.translations']
# path to the file to put in empty directories
# fixes https://bugs.launchpad.net/wicd/+bug/503028
empty_file = 'other/.empty_on_purpose'
# if there's no wpath.py, then run configure+build
print 'Running configure with default parameters.'
for cmd in [configure,build]:
cmd(self.distribution).run()
try:
print "Using init file",(wpath.init, wpath.initfile)
data = [
data.extend([
(wpath.dbus, ['other/wicd.conf']),
(wpath.dbus_service, ['other/org.wicd.daemon.service']),
(wpath.systemd, ['other/wicd.service']),
@@ -518,8 +442,8 @@ try:
(wpath.predisconnectscripts, [empty_file]),
(wpath.postdisconnectscripts, [empty_file]),
(wpath.preconnectscripts, [empty_file]),
(wpath.postconnectscripts, [empty_file]),
]
(wpath.postconnectscripts, [empty_file])
])
if not wpath.no_install_gtk:
data.append((wpath.desktop, ['other/wicd.desktop']))
@@ -602,8 +526,9 @@ try:
if not wpath.no_install_pmutils:
data.append((wpath.pmutils, ['other/55wicd']))
print 'Using pid path', os.path.basename(wpath.pidfile)
if not wpath.no_install_i18n:
print 'Language support for',
for pofile in glob('po/*.po'):
for pofile in sorted(glob('po/*.po')):
language = pofile.replace('po/', '').replace('.po', '')
print language,
data.append((wpath.translations + language + '/LC_MESSAGES/',
@@ -614,6 +539,98 @@ except Exception, e:
print '''Error setting up data array. This is normal if
python setup.py configure has not yet been run.'''
_install.run(self)
class test(Command):
description = "run Wicd's unit tests"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
print "importing tests"
import tests
print 'running tests'
tests.run_tests()
class update_message_catalog(Command):
description = "update wicd.pot with new strings"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system('pybabel extract . -o po/wicd.pot --sort-output')
os.system('xgettext -L glade data/wicd.ui -j -o po/wicd.pot')
class update_translations(Command):
description = "update po-files with new strings from wicd.pot"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
for pofile in glob('po/*.po'):
lang = pofile.replace('po/', '').replace('.po', '')
os.system('pybabel update -N -o %s -i po/wicd.pot -D wicd -l %s' % (pofile, lang))
class compile_translations(Command):
description = 'compile po-files to binary mo'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
import wpath
if not wpath.no_install_i18n:
if os.path.exists('translations'):
shutil.rmtree('translations/')
os.makedirs('translations')
for pofile in sorted(glob('po/*.po')):
lang = pofile.replace('po/', '').replace('.po', '')
os.makedirs('translations/' + lang + '/LC_MESSAGES/')
os.system('pybabel compile -D wicd -i %s -l %s -d translations/' % (pofile, lang))
class uninstall(Command):
description = "remove Wicd using uninstall.sh and install.log"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
os.system("./uninstall.sh")
py_modules = ['wicd.networking','wicd.misc','wicd.wnettools',
'wicd.wpath','wicd.dbusmanager',
'wicd.logfile','wicd.backend','wicd.configmanager',
'wicd.translations']
wpactrl_ext = Extension(name = 'wpactrl',
sources = ['depends/python-wpactrl/wpa_ctrl.c',
@@ -625,7 +642,9 @@ iwscan_ext = Extension(name = 'iwscan', libraries = ['iw'],
setup(
cmdclass = {
'build' : build,
'configure' : configure,
'install' : install,
'uninstall' : uninstall,
'test' : test,
'clear_generated' : clear_generated,