libtoolimporter: Don't assume we have a multi-component import
authorColin Walters <walters@verbum.org>
Tue, 9 Nov 2010 14:15:13 +0000 (09:15 -0500)
committerColin Walters <walters@verbum.org>
Tue, 9 Nov 2010 16:52:29 +0000 (11:52 -0500)
os.path.join barfs if we're passing it 0 arguments, as would happen
when doing "import foo".

giscanner/libtoolimporter.py

index 84c62f9..20bd005 100644 (file)
@@ -41,10 +41,14 @@ class LibtoolImporter(object):
         # should be looked for. See if we can find a ".libs/module.la" relative
         # to those directories and failing that look for file
         # "some/package/.libs/module.la" relative to sys.path
-        module = os.path.join(*modparts)
+        if len(modparts) > 0:
+            modprefix = os.path.join(*modparts)
+            modprefix = os.path.join(modprefix, '.libs')
+        else:
+            modprefix = '.libs'
 
         for path in sys.path:
-            full = os.path.join(path, module, '.libs', filename)
+            full = os.path.join(path, modprefix, filename)
             if os.path.exists(full):
                 return cls(name, full)