From 9949185214c0b00059cfdb63b5b868638a2e521d Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Mon, 23 Aug 2010 16:35:01 +0300 Subject: [PATCH] Modify build script to install locales When fpdb is built, the prebuilt .mo files from locale/$LANG/$TYPE/ are now automatically copied to target directory. For debian builds this means that all locales are placed in $INSTROOT/usr/share/locale and should be instantly usable for inclusion. --- setup.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/setup.py b/setup.py index 83e46a0c..f114553d 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,36 @@ # Python packaging for fpdb from distutils.core import setup +from distutils.command.install_data import install_data as INST + +import glob, string, os + + +class inst_translations(INST): + + # Return triples for installations + def __locales(self, rootdir): + _globstr = '%s/*/*/*.mo' % rootdir + paths = glob.glob(_globstr) + _locales = [] + for p in paths: + rp = string.split(p, '/', 2) + (lang, loc, mo) = string.split(rp[2], '/') + _locales.append( (lang, loc, mo) ) + return _locales + + def run(self): + locales = self.__locales('pyfpdb/locale') + for (lang, loc, mo_file) in locales: + lang_dir = os.path.join('share', 'locale', lang, loc) + lang_file = os.path.join('pyfpdb/locale', lang, loc, mo_file) + self.data_files.append( (lang_dir, [lang_file]) ) + INST.run(self) + + +commands = { + 'install_data': inst_translations +} setup(name = 'fpdb', description = 'Free Poker Database', @@ -18,6 +48,7 @@ setup(name = 'fpdb', author_email = 'fpdb-main@lists.sourceforge.net', packages = ['fpdb'], package_dir = { 'fpdb' : 'pyfpdb' }, + cmdclass = commands, data_files = [ ('/usr/share/pixmaps', ['gfx/fpdb-icon.png', 'gfx/fpdb-icon2.png',