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%

297
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,6 +412,135 @@ class clear_generated(Command):
shutil.rmtree('translations/')
os.makedirs('translations/')
class install(_install):
def run(self):
try:
import wpath
except ImportError:
# 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.extend([
(wpath.dbus, ['other/wicd.conf']),
(wpath.dbus_service, ['other/org.wicd.daemon.service']),
(wpath.systemd, ['other/wicd.service']),
(wpath.logrotate, ['other/wicd.logrotate']),
(wpath.log, [empty_file]),
(wpath.etc, ['other/dhclient.conf.template.default']),
(wpath.encryption, [('encryption/templates/' + b) for b in
os.listdir('encryption/templates') if not b.startswith('.')]),
(wpath.networks, [empty_file]),
(wpath.sbin, ['scripts/wicd']),
(wpath.daemon, ['wicd/monitor.py', 'wicd/wicd-daemon.py',
'wicd/suspend.py', 'wicd/autoconnect.py']),
(wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),
(wpath.scripts, [empty_file]),
(wpath.predisconnectscripts, [empty_file]),
(wpath.postdisconnectscripts, [empty_file]),
(wpath.preconnectscripts, [empty_file]),
(wpath.postconnectscripts, [empty_file])
])
if not wpath.no_install_gtk:
data.append((wpath.desktop, ['other/wicd.desktop']))
data.append((wpath.bin, ['scripts/wicd-client']))
data.append((wpath.bin, ['scripts/wicd-gtk']))
data.append((wpath.gtk, [
'gtk/wicd-client.py',
'gtk/netentry.py',
'gtk/prefs.py',
'gtk/gui.py',
'gtk/guiutil.py',
'data/wicd.ui',
'gtk/configscript.py',
]))
data.append((wpath.autostart, ['other/wicd-tray.desktop']))
if not wpath.no_install_man:
data.append((wpath.mandir + 'man1/', [ 'man/wicd-client.1' ]))
data.append((wpath.icons + 'scalable/apps/', ['icons/scalable/wicd-gtk.svg']))
data.append((wpath.icons + '192x192/apps/', ['icons/192px/wicd-gtk.png']))
data.append((wpath.icons + '128x128/apps/', ['icons/128px/wicd-gtk.png']))
data.append((wpath.icons + '96x96/apps/', ['icons/96px/wicd-gtk.png']))
data.append((wpath.icons + '72x72/apps/', ['icons/72px/wicd-gtk.png']))
data.append((wpath.icons + '64x64/apps/', ['icons/64px/wicd-gtk.png']))
data.append((wpath.icons + '48x48/apps/', ['icons/48px/wicd-gtk.png']))
data.append((wpath.icons + '36x36/apps/', ['icons/36px/wicd-gtk.png']))
data.append((wpath.icons + '32x32/apps/', ['icons/32px/wicd-gtk.png']))
data.append((wpath.icons + '24x24/apps/', ['icons/24px/wicd-gtk.png']))
data.append((wpath.icons + '22x22/apps/', ['icons/22px/wicd-gtk.png']))
data.append((wpath.icons + '16x16/apps/', ['icons/16px/wicd-gtk.png']))
data.append((wpath.images, [('images/' + b) for b in os.listdir('images') if not b.startswith('.')]))
data.append((wpath.pixmaps, ['other/wicd-gtk.xpm']))
if not wpath.no_install_ncurses:
data.append((wpath.curses, ['curses/curses_misc.py']))
data.append((wpath.curses, ['curses/prefs_curses.py']))
data.append((wpath.curses, ['curses/wicd-curses.py']))
data.append((wpath.curses, ['curses/netentry_curses.py']))
data.append((wpath.curses, ['curses/configscript_curses.py']))
data.append((wpath.bin, ['scripts/wicd-curses']))
if not wpath.no_install_man:
data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8']))
if not wpath.no_install_man and not wpath.no_install_i18n_man:
data.append(( wpath.mandir + 'nl/man8/', ['man/nl/wicd-curses.8']))
if not wpath.no_install_docs:
data.append(( wpath.docdir, ['curses/README.curses']))
if not wpath.no_install_cli:
data.append((wpath.cli, ['cli/wicd-cli.py']))
data.append((wpath.bin, ['scripts/wicd-cli']))
if not wpath.no_install_man:
data.append(( wpath.mandir + 'man8/', ['man/wicd-cli.8']))
if not wpath.no_install_docs:
data.append(( wpath.docdir, ['cli/README.cli']))
piddir = os.path.dirname(wpath.pidfile)
if not piddir.endswith('/'):
piddir += '/'
if not wpath.no_install_docs:
data.append((wpath.docdir, ['INSTALL', 'LICENSE', 'AUTHORS',
'README', 'CHANGES', ]))
data.append((wpath.varlib, ['other/WHEREAREMYFILES']))
if not wpath.no_install_kde:
if not wpath.no_install_gtk:
data.append((wpath.kdedir, ['other/wicd-tray.desktop']))
if not wpath.no_install_init:
data.append((wpath.init, [ wpath.initfile ]))
if not wpath.no_install_man:
data.append((wpath.mandir + 'man8/', ['man/wicd.8']))
data.append((wpath.mandir + 'man5/', ['man/wicd-manager-settings.conf.5']))
data.append((wpath.mandir + 'man5/', ['man/wicd-wired-settings.conf.5']))
data.append((wpath.mandir + 'man5/', ['man/wicd-wireless-settings.conf.5']))
data.append((wpath.mandir + 'man1/', ['man/wicd-client.1']))
if not wpath.no_install_man and not wpath.no_install_i18n_man:
# Dutch translations of the man
data.append((wpath.mandir + 'nl/man8/', ['man/nl/wicd.8' ]))
data.append((wpath.mandir + 'nl/man5/', ['man/nl/wicd-manager-settings.conf.5']))
data.append((wpath.mandir + 'nl/man5/', ['man/nl/wicd-wired-settings.conf.5']))
data.append((wpath.mandir + 'nl/man5/', ['man/nl/wicd-wireless-settings.conf.5']))
data.append((wpath.mandir + 'nl/man1/', ['man/nl/wicd-client.1']))
if not wpath.no_install_acpi:
data.append((wpath.resume, ['other/80-wicd-connect.sh']))
data.append((wpath.suspend, ['other/50-wicd-suspend.sh']))
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 sorted(glob('po/*.po')):
language = pofile.replace('po/', '').replace('.po', '')
print language,
data.append((wpath.translations + language + '/LC_MESSAGES/',
['translations/' + language + '/LC_MESSAGES/wicd.mo']))
print
except Exception, e:
print str(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"
@@ -456,15 +599,18 @@ class compile_translations(Command):
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))
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):
@@ -481,140 +627,11 @@ class uninstall(Command):
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'
try:
print "Using init file",(wpath.init, wpath.initfile)
data = [
(wpath.dbus, ['other/wicd.conf']),
(wpath.dbus_service, ['other/org.wicd.daemon.service']),
(wpath.systemd, ['other/wicd.service']),
(wpath.logrotate, ['other/wicd.logrotate']),
(wpath.log, [empty_file]),
(wpath.etc, ['other/dhclient.conf.template.default']),
(wpath.encryption, [('encryption/templates/' + b) for b in
os.listdir('encryption/templates') if not b.startswith('.')]),
(wpath.networks, [empty_file]),
(wpath.sbin, ['scripts/wicd']),
(wpath.daemon, ['wicd/monitor.py', 'wicd/wicd-daemon.py',
'wicd/suspend.py', 'wicd/autoconnect.py']),
(wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),
(wpath.scripts, [empty_file]),
(wpath.predisconnectscripts, [empty_file]),
(wpath.postdisconnectscripts, [empty_file]),
(wpath.preconnectscripts, [empty_file]),
(wpath.postconnectscripts, [empty_file]),
]
if not wpath.no_install_gtk:
data.append((wpath.desktop, ['other/wicd.desktop']))
data.append((wpath.bin, ['scripts/wicd-client']))
data.append((wpath.bin, ['scripts/wicd-gtk']))
data.append((wpath.gtk, [
'gtk/wicd-client.py',
'gtk/netentry.py',
'gtk/prefs.py',
'gtk/gui.py',
'gtk/guiutil.py',
'data/wicd.ui',
'gtk/configscript.py',
]))
data.append((wpath.autostart, ['other/wicd-tray.desktop']))
if not wpath.no_install_man:
data.append((wpath.mandir + 'man1/', [ 'man/wicd-client.1' ]))
data.append((wpath.icons + 'scalable/apps/', ['icons/scalable/wicd-gtk.svg']))
data.append((wpath.icons + '192x192/apps/', ['icons/192px/wicd-gtk.png']))
data.append((wpath.icons + '128x128/apps/', ['icons/128px/wicd-gtk.png']))
data.append((wpath.icons + '96x96/apps/', ['icons/96px/wicd-gtk.png']))
data.append((wpath.icons + '72x72/apps/', ['icons/72px/wicd-gtk.png']))
data.append((wpath.icons + '64x64/apps/', ['icons/64px/wicd-gtk.png']))
data.append((wpath.icons + '48x48/apps/', ['icons/48px/wicd-gtk.png']))
data.append((wpath.icons + '36x36/apps/', ['icons/36px/wicd-gtk.png']))
data.append((wpath.icons + '32x32/apps/', ['icons/32px/wicd-gtk.png']))
data.append((wpath.icons + '24x24/apps/', ['icons/24px/wicd-gtk.png']))
data.append((wpath.icons + '22x22/apps/', ['icons/22px/wicd-gtk.png']))
data.append((wpath.icons + '16x16/apps/', ['icons/16px/wicd-gtk.png']))
data.append((wpath.images, [('images/' + b) for b in os.listdir('images') if not b.startswith('.')]))
data.append((wpath.pixmaps, ['other/wicd-gtk.xpm']))
if not wpath.no_install_ncurses:
data.append((wpath.curses, ['curses/curses_misc.py']))
data.append((wpath.curses, ['curses/prefs_curses.py']))
data.append((wpath.curses, ['curses/wicd-curses.py']))
data.append((wpath.curses, ['curses/netentry_curses.py']))
data.append((wpath.curses, ['curses/configscript_curses.py']))
data.append((wpath.bin, ['scripts/wicd-curses']))
if not wpath.no_install_man:
data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8']))
if not wpath.no_install_man and not wpath.no_install_i18n_man:
data.append(( wpath.mandir + 'nl/man8/', ['man/nl/wicd-curses.8']))
if not wpath.no_install_docs:
data.append(( wpath.docdir, ['curses/README.curses']))
if not wpath.no_install_cli:
data.append((wpath.cli, ['cli/wicd-cli.py']))
data.append((wpath.bin, ['scripts/wicd-cli']))
if not wpath.no_install_man:
data.append(( wpath.mandir + 'man8/', ['man/wicd-cli.8']))
if not wpath.no_install_docs:
data.append(( wpath.docdir, ['cli/README.cli']))
piddir = os.path.dirname(wpath.pidfile)
if not piddir.endswith('/'):
piddir += '/'
if not wpath.no_install_docs:
data.append((wpath.docdir, ['INSTALL', 'LICENSE', 'AUTHORS',
'README', 'CHANGES', ]))
data.append((wpath.varlib, ['other/WHEREAREMYFILES']))
if not wpath.no_install_kde:
if not wpath.no_install_gtk:
data.append((wpath.kdedir, ['other/wicd-tray.desktop']))
if not wpath.no_install_init:
data.append((wpath.init, [ wpath.initfile ]))
if not wpath.no_install_man:
data.append((wpath.mandir + 'man8/', ['man/wicd.8']))
data.append((wpath.mandir + 'man5/', ['man/wicd-manager-settings.conf.5']))
data.append((wpath.mandir + 'man5/', ['man/wicd-wired-settings.conf.5']))
data.append((wpath.mandir + 'man5/', ['man/wicd-wireless-settings.conf.5']))
data.append((wpath.mandir + 'man1/', ['man/wicd-client.1']))
if not wpath.no_install_man and not wpath.no_install_i18n_man:
# Dutch translations of the man
data.append((wpath.mandir + 'nl/man8/', ['man/nl/wicd.8' ]))
data.append((wpath.mandir + 'nl/man5/', ['man/nl/wicd-manager-settings.conf.5']))
data.append((wpath.mandir + 'nl/man5/', ['man/nl/wicd-wired-settings.conf.5']))
data.append((wpath.mandir + 'nl/man5/', ['man/nl/wicd-wireless-settings.conf.5']))
data.append((wpath.mandir + 'nl/man1/', ['man/nl/wicd-client.1']))
if not wpath.no_install_acpi:
data.append((wpath.resume, ['other/80-wicd-connect.sh']))
data.append((wpath.suspend, ['other/50-wicd-suspend.sh']))
if not wpath.no_install_pmutils:
data.append((wpath.pmutils, ['other/55wicd']))
print 'Using pid path', os.path.basename(wpath.pidfile)
print 'Language support for',
for pofile in glob('po/*.po'):
language = pofile.replace('po/', '').replace('.po', '')
print language,
data.append((wpath.translations + language + '/LC_MESSAGES/',
['translations/' + language + '/LC_MESSAGES/wicd.mo']))
print
except Exception, e:
print str(e)
print '''Error setting up data array. This is normal if
python setup.py configure has not yet been run.'''
wpactrl_ext = Extension(name = 'wpactrl',
sources = ['depends/python-wpactrl/wpa_ctrl.c',
'depends/python-wpactrl/wpactrl.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,