Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/setup.py
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2011-04-12 11:23:32 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2011-04-12 11:23:32 (GMT)
commit9425fc693d3c095c93c776c90aa2095b78ec0d91 (patch)
tree458dd21bb6d1056d744e563221af0c3fc8b01245 /setup.py
parent8e35c43b3318f92018b4b2a43d267aa832cad37a (diff)
add installer
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py96
1 files changed, 96 insertions, 0 deletions
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..b51ab57
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+#
+# Author: Sascha Silbe <sascha-pgp@silbe.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Installer for gdatastore
+"""
+
+from distutils import log
+from distutils.command.install import install as _install
+from distutils.core import Command, setup
+from distutils.util import convert_path
+import glob
+import os
+
+
+class install_dbus(Command): # pylint: disable=C0103,R0904
+ """Install D-Bus service files."""
+
+ description = 'create D-Bus service files from templates'
+
+ user_options = [
+ ('install-dir=', 'd',
+ "base directory for installing data files "
+ "(default: installation base dir)"),
+ ('root=', None,
+ "install everything relative to this alternate root directory"),
+ ('force', 'f', "force installation (overwrite existing files)"),
+ ]
+
+ boolean_options = ['force']
+
+ def initialize_options(self):
+ # pylint: disable=W0201
+ self.install_dir = None
+ self.outfiles = []
+ self.root = None
+ self.force = 0
+
+ def finalize_options(self):
+ self.set_undefined_options('install',
+ ('install_data', 'install_dir'),
+ ('root', 'root'),
+ ('force', 'force'),
+ )
+
+ def run(self):
+ self.mkpath(self.install_dir)
+ service_file_names = []
+ dbus_dir = convert_path(os.path.join(self.install_dir,
+ 'share/dbus-1/services'))
+ self.mkpath(dbus_dir)
+ for template_file_name in glob.glob('*.service.in'):
+ service_file_name = template_file_name[:-3]
+ service_path = os.path.join(dbus_dir, service_file_name)
+ log.info('Writing %s', service_path)
+ if not self.dry_run:
+ self.process_template(template_file_name, service_path)
+ self.outfiles.append(service_path)
+
+ def process_template(self, template_path, service_path):
+ """Copy template_path to service_path, replacing format specifiers.
+ """
+ variables = {'install_dir': self.install_dir, 'root': self.root}
+ with file(service_path, 'w') as service_file:
+ for line in file(template_path):
+ service_file.write(line % variables)
+
+
+class install(_install): # pylint: disable=C0103,R0904
+ """'install' command with support for D-Bus service files"""
+ sub_commands = _install.sub_commands + [('install_dbus', None)]
+
+
+setup(name='gdatastore',
+ version='0.1',
+ #url='',
+ description='a generic blob+metadata storage not only for Sugar',
+ author='Sascha Silbe',
+ author_email='sascha-pgp@silbe.org',
+ license='GPLv3',
+ cmdclass={'install': install, 'install_dbus': install_dbus},
+ packages=['gdatastore'],
+ scripts=['bin/gdatastore-service'],
+ )