mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Re-organize setup.py, provide a --no-install-i18n
This commit is contained in:
@@ -78,6 +78,7 @@ log_perms = '%LOGPERMS%'
|
|||||||
no_install_pmutils = %NO_INSTALL_PMUTILS%
|
no_install_pmutils = %NO_INSTALL_PMUTILS%
|
||||||
no_install_init = %NO_INSTALL_INIT%
|
no_install_init = %NO_INSTALL_INIT%
|
||||||
no_install_man = %NO_INSTALL_MAN%
|
no_install_man = %NO_INSTALL_MAN%
|
||||||
|
no_install_i18n = %NO_INSTALL_I18N%
|
||||||
no_install_i18n_man = %NO_INSTALL_I18N_MAN%
|
no_install_i18n_man = %NO_INSTALL_I18N_MAN%
|
||||||
no_install_kde = %NO_INSTALL_KDE%
|
no_install_kde = %NO_INSTALL_KDE%
|
||||||
no_install_acpi = %NO_INSTALL_ACPI%
|
no_install_acpi = %NO_INSTALL_ACPI%
|
||||||
|
|||||||
221
setup.py
221
setup.py
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
from distutils.core import setup, Command
|
from distutils.core import setup, Command
|
||||||
from distutils.extension import Extension
|
from distutils.extension import Extension
|
||||||
|
from distutils.command.build import build as _build
|
||||||
|
from distutils.command.install import install as _install
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
@@ -32,6 +34,12 @@ VERSION_NUM = '1.7.2.4'
|
|||||||
REVISION_NUM = 'unknown'
|
REVISION_NUM = 'unknown'
|
||||||
CURSES_REVNO = 'uimod'
|
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
|
# change to the directory setup.py is contained in
|
||||||
os.chdir(os.path.abspath(os.path.split(__file__)[0]))
|
os.chdir(os.path.abspath(os.path.split(__file__)[0]))
|
||||||
|
|
||||||
@@ -47,6 +55,12 @@ except Exception, e:
|
|||||||
print 'failed to find revision number:'
|
print 'failed to find revision number:'
|
||||||
print e
|
print e
|
||||||
|
|
||||||
|
class build(_build):
|
||||||
|
sub_commands = _build.sub_commands + [('compile_translations', None)]
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
_build.run(self)
|
||||||
|
|
||||||
class configure(Command):
|
class configure(Command):
|
||||||
description = "configure the paths that Wicd will be installed to"
|
description = "configure the paths that Wicd will be installed to"
|
||||||
|
|
||||||
@@ -102,6 +116,7 @@ class configure(Command):
|
|||||||
# Configure switches
|
# Configure switches
|
||||||
('no-install-init', None, "do not install the init file"),
|
('no-install-init', None, "do not install the init file"),
|
||||||
('no-install-man', None, 'do not install the man files'),
|
('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-i18n-man', None, 'do not install the translated man files'),
|
||||||
('no-install-kde', None, 'do not install the kde autostart file'),
|
('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'),
|
('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_init = False
|
||||||
self.no_install_man = False
|
self.no_install_man = False
|
||||||
|
self.no_install_i18n = False
|
||||||
self.no_install_i18n_man = False
|
self.no_install_i18n_man = False
|
||||||
self.no_install_kde = False
|
self.no_install_kde = False
|
||||||
self.no_install_acpi = False
|
self.no_install_acpi = False
|
||||||
@@ -366,8 +382,6 @@ class configure(Command):
|
|||||||
item_in.close()
|
item_in.close()
|
||||||
shutil.copymode(original_name, final_name)
|
shutil.copymode(original_name, final_name)
|
||||||
|
|
||||||
trans = compile_translations(self.distribution)
|
|
||||||
trans.run()
|
|
||||||
|
|
||||||
class clear_generated(Command):
|
class clear_generated(Command):
|
||||||
description = 'clears out files generated by configure'
|
description = 'clears out files generated by configure'
|
||||||
@@ -398,109 +412,19 @@ class clear_generated(Command):
|
|||||||
shutil.rmtree('translations/')
|
shutil.rmtree('translations/')
|
||||||
os.makedirs('translations/')
|
os.makedirs('translations/')
|
||||||
|
|
||||||
class test(Command):
|
class install(_install):
|
||||||
description = "run Wicd's unit tests"
|
|
||||||
|
|
||||||
user_options = []
|
|
||||||
|
|
||||||
def initialize_options(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def finalize_options(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
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:
|
try:
|
||||||
import wpath
|
import wpath
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print '''Error importing wpath.py. You can safely ignore this
|
# if there's no wpath.py, then run configure+build
|
||||||
message. It is probably because you haven't run python setup.py
|
print 'Running configure with default parameters.'
|
||||||
configure yet or you are running it for the first time.'''
|
for cmd in [configure,build]:
|
||||||
|
cmd(self.distribution).run()
|
||||||
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'
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print "Using init file",(wpath.init, wpath.initfile)
|
print "Using init file",(wpath.init, wpath.initfile)
|
||||||
data = [
|
data.extend([
|
||||||
(wpath.dbus, ['other/wicd.conf']),
|
(wpath.dbus, ['other/wicd.conf']),
|
||||||
(wpath.dbus_service, ['other/org.wicd.daemon.service']),
|
(wpath.dbus_service, ['other/org.wicd.daemon.service']),
|
||||||
(wpath.systemd, ['other/wicd.service']),
|
(wpath.systemd, ['other/wicd.service']),
|
||||||
@@ -518,8 +442,8 @@ try:
|
|||||||
(wpath.predisconnectscripts, [empty_file]),
|
(wpath.predisconnectscripts, [empty_file]),
|
||||||
(wpath.postdisconnectscripts, [empty_file]),
|
(wpath.postdisconnectscripts, [empty_file]),
|
||||||
(wpath.preconnectscripts, [empty_file]),
|
(wpath.preconnectscripts, [empty_file]),
|
||||||
(wpath.postconnectscripts, [empty_file]),
|
(wpath.postconnectscripts, [empty_file])
|
||||||
]
|
])
|
||||||
|
|
||||||
if not wpath.no_install_gtk:
|
if not wpath.no_install_gtk:
|
||||||
data.append((wpath.desktop, ['other/wicd.desktop']))
|
data.append((wpath.desktop, ['other/wicd.desktop']))
|
||||||
@@ -602,8 +526,9 @@ try:
|
|||||||
if not wpath.no_install_pmutils:
|
if not wpath.no_install_pmutils:
|
||||||
data.append((wpath.pmutils, ['other/55wicd']))
|
data.append((wpath.pmutils, ['other/55wicd']))
|
||||||
print 'Using pid path', os.path.basename(wpath.pidfile)
|
print 'Using pid path', os.path.basename(wpath.pidfile)
|
||||||
|
if not wpath.no_install_i18n:
|
||||||
print 'Language support for',
|
print 'Language support for',
|
||||||
for pofile in glob('po/*.po'):
|
for pofile in sorted(glob('po/*.po')):
|
||||||
language = pofile.replace('po/', '').replace('.po', '')
|
language = pofile.replace('po/', '').replace('.po', '')
|
||||||
print language,
|
print language,
|
||||||
data.append((wpath.translations + language + '/LC_MESSAGES/',
|
data.append((wpath.translations + language + '/LC_MESSAGES/',
|
||||||
@@ -614,6 +539,98 @@ except Exception, e:
|
|||||||
print '''Error setting up data array. This is normal if
|
print '''Error setting up data array. This is normal if
|
||||||
python setup.py configure has not yet been run.'''
|
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',
|
wpactrl_ext = Extension(name = 'wpactrl',
|
||||||
sources = ['depends/python-wpactrl/wpa_ctrl.c',
|
sources = ['depends/python-wpactrl/wpa_ctrl.c',
|
||||||
@@ -625,7 +642,9 @@ iwscan_ext = Extension(name = 'iwscan', libraries = ['iw'],
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
cmdclass = {
|
cmdclass = {
|
||||||
|
'build' : build,
|
||||||
'configure' : configure,
|
'configure' : configure,
|
||||||
|
'install' : install,
|
||||||
'uninstall' : uninstall,
|
'uninstall' : uninstall,
|
||||||
'test' : test,
|
'test' : test,
|
||||||
'clear_generated' : clear_generated,
|
'clear_generated' : clear_generated,
|
||||||
|
|||||||
Reference in New Issue
Block a user