#!/usr/bin/env python3 import distutils.core import distutils.command.build import distutils.command.install import glob import os class build_pylock(distutils.command.build.build): def run(self): distutils.command.build.build.run(self) data_files = self.distribution.data_files if data_files is None: # in case not data_files are defined in setup.py self.distribution.data_files = data_files = [] for po_file in glob.glob("po/*.po"): lang = os.path.basename(po_file[:-3]) mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES") mo_file = os.path.join(mo_dir, "%s.mo" % self.distribution.metadata.name) if not os.path.exists(mo_dir): os.makedirs(mo_dir) cmd = ["msgfmt", po_file, "-o", mo_file] po_mtime = os.path.getmtime(po_file) mo_mtime = os.path.exists(mo_file) and os.path.getmtime(mo_file) or 0 if po_mtime > mo_mtime: self.spawn(cmd) targetpath = os.path.join("share/locale", lang, "LC_MESSAGES") data_files.append((targetpath, (mo_file,))) class install_pylock(distutils.command.install.install): def run(self): distutils.command.install.install.run(self) distutils.dir_util.copy_tree('etc', os.path.join(self.root, 'etc'), preserve_times=0, preserve_symlinks=1, verbose=1) distutils.core.setup( name = 'pylock', version = '3', author = 'Matthias Schiffer', author_email = 'mschiffer@universe-factory.net', url = 'http://git.universe-factory.net/pylock/', description = 'A lightweight screenlocker for X implemented in Python 3 using Gtk3', license = 'BSD', packages = ['pylock'], package_data = { 'pylock': ['data/unlock.ui', 'data/bg.svg'], }, scripts = ['scripts/pylock'], cmdclass = { 'build': build_pylock, 'install': install_pylock, }, provides = ['pylock'], requires = [ 'gi.repository.Gtk', 'gi.repository.Gdk', 'gi.repository.GdkX11', 'gi.repository.GObject', 'gi.repository.GLib', ], )