diff options
author | Johan Dahlin <johan@gnome.org> | 2008-10-21 14:51:33 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-10-21 14:51:33 +0000 |
commit | 92c3708208b068139f3bdc9a9783244d5b4b4b8c (patch) | |
tree | 6853f3b08ad9e91b603e271cb53922beff47b4b5 /giscanner/libtoolimporter.py | |
parent | d317722b94d3d7a5f68c68fe1c1f90fea3cb81f3 (diff) | |
download | gobject-introspection-92c3708208b068139f3bdc9a9783244d5b4b4b8c.tar.gz |
Bug 556358 - don't use libtool internals
2008-10-21 Johan Dahlin <johan@gnome.org>
Bug 556358 - don't use libtool internals
* giscanner/Makefile.am:
* giscanner/libtoolimporter.py:
* giscanner/sourcescanner.py:
* giscanner/utils.py:
Add a python meta importer and remove a libtool symlink hack.
svn path=/trunk/; revision=767
Diffstat (limited to 'giscanner/libtoolimporter.py')
-rw-r--r-- | giscanner/libtoolimporter.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/giscanner/libtoolimporter.py b/giscanner/libtoolimporter.py new file mode 100644 index 00000000..2971815e --- /dev/null +++ b/giscanner/libtoolimporter.py @@ -0,0 +1,52 @@ +# -*- Mode: Python -*- +# GObject-Introspection - a framework for introspecting GObject libraries +# Copyright (C) 2008 Johan Dahlin +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. +# + +import imp +import os +import sys + +from .utils import extract_libtool + + +class LibToolImporter(object): + def __init__(self, name, path): + self.name = name + self.path = path + + @staticmethod + def find_module(name, path=None): + modname = name.split('.')[-1] + for part in path or sys.path: + full = os.path.join(part, '.libs', modname + '.la') + if os.path.exists(full): + return LibToolImporter(name, full) + raise SystemExit + + def load_module(self, name): + realpath = extract_libtool(self.path) + mod = imp.load_module(name, open(realpath), realpath, + ('.so', 'rb', 3)) + return mod + +def install_libtoolimporter(): + sys.meta_path.append(LibToolImporter) + +def uninstall_libtoolimporter(): + sys.meta_path.remove(LibToolImporter) |