1 #!/usr/bin/env @PYTHON@
3 # GDBus - GLib D-Bus Library
5 # Copyright (C) 2008-2011 Red Hat, Inc.
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.
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.
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/>.
20 # Author: David Zeuthen <davidz@redhat.com>
26 srcdir = os.getenv('UNINSTALLED_GLIB_SRCDIR', None)
27 filedir = os.path.dirname(__file__)
29 if srcdir is not None:
30 path = os.path.join(srcdir, 'gio', 'gdbus-2.0')
31 elif 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')
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, '..')
40 # Canonicalize, then do further testing
41 path = os.path.abspath(path)
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.
47 # In these cases our installation cannot be relocatable, but at least we should
48 # be able to find the codegen module.
49 if not os.path.isfile(os.path.join(path, 'codegen', 'codegen_main.py')):
50 path = os.path.join('@DATADIR@', 'glib-2.0')
52 sys.path.insert(0, path)
53 from codegen import codegen_main
55 sys.exit(codegen_main.codegen_main())