2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2008 Johan Dahlin
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 from .utils import extract_libtool
28 class LibToolImporter(object):
29 def __init__(self, name, path):
34 def find_module(name, path=None):
35 modname = name.split('.')[-1]
36 for part in path or sys.path:
37 full = os.path.join(part, '.libs', modname + '.la')
38 if os.path.exists(full):
39 return LibToolImporter(name, full)
41 def load_module(self, name):
42 realpath = extract_libtool(self.path)
43 mod = imp.load_module(name, open(realpath), realpath,
47 def install_libtoolimporter():
48 sys.meta_path.append(LibToolImporter)
50 def uninstall_libtoolimporter():
51 sys.meta_path.remove(LibToolImporter)