1#!/usr/bin/env @PYTHON@ 2 3# GDBus - GLib D-Bus Library 4# 5# Copyright (C) 2008-2011 Red Hat, Inc. 6# 7# This library is free software; you can redistribute it and/or 8# modify it under the terms of the GNU Lesser General Public 9# License as published by the Free Software Foundation; either 10# version 2.1 of the License, or (at your option) any later version. 11# 12# This library is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15# Lesser General Public License for more details. 16# 17# You should have received a copy of the GNU Lesser General 18# Public License along with this library; if not, see <http://www.gnu.org/licenses/>. 19# 20# Author: David Zeuthen <davidz@redhat.com> 21 22 23import os 24import sys 25 26srcdir = os.getenv('UNINSTALLED_GLIB_SRCDIR', None) 27filedir = os.path.dirname(__file__) 28 29if srcdir is not None: 30 path = os.path.join(srcdir, 'gio', 'gdbus-2.0') 31elif os.path.basename(filedir) == 'bin': 32 # Make the prefix containing gdbus-codegen 'relocatable' at runtime by 33 # adding /some/prefix/bin/../share/glib-2.0 to the python path 34 path = os.path.join(filedir, '..', 'share', 'glib-2.0') 35else: 36 # Assume that the modules we need are in the current directory and add the 37 # parent directory to the python path. 38 path = os.path.join(filedir, '..') 39 40# Canonicalize, then do further testing 41path = os.path.abspath(path) 42 43# If the above path detection failed, use the hard-coded datadir. This can 44# happen when, for instance, bindir and datadir are not in the same prefix or 45# on Windows where we cannot make any guarantees about the directory structure. 46# 47# In these cases our installation cannot be relocatable, but at least we should 48# be able to find the codegen module. 49if not os.path.isfile(os.path.join(path, 'codegen', 'codegen_main.py')): 50 path = os.path.join('@DATADIR@', 'glib-2.0') 51 52sys.path.insert(0, path) 53from codegen import codegen_main 54 55sys.exit(codegen_main.codegen_main()) 56