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):
30 def __init__(self, name, path):
35 def find_module(name, path=None):
36 modname = name.split('.')[-1]
37 for part in path or sys.path:
38 full = os.path.join(part, '.libs', modname + '.la')
39 if os.path.exists(full):
40 return LibToolImporter(name, full)
42 def load_module(self, name):
43 realpath = extract_libtool(self.path)
44 mod = imp.load_module(name, open(realpath), realpath,
49 def install_libtoolimporter():
50 sys.meta_path.append(LibToolImporter)
53 def uninstall_libtoolimporter():
54 sys.meta_path.remove(LibToolImporter)