Make sure we always yield full names

This commit is contained in:
Florian Bruhin 2018-12-10 11:41:37 +01:00
parent 6bc771151f
commit bb115afc1a
2 changed files with 10 additions and 4 deletions

View File

@ -32,7 +32,7 @@ def get_data_files():
def get_hidden_imports():
imports = ['PyQt5.QtOpenGL', 'PyQt5._QOpenGLFunctions_2_0']
for info in loader.walk_components():
imports.append('qutebrowser.components.' + info.name)
imports.append(info.name)
return imports

View File

@ -51,13 +51,19 @@ def walk_components() -> typing.Iterator[ComponentInfo]:
yield from _walk_normal()
def _walk_error(name: str):
raise ImportError("Failed to import {}".format(name))
def _walk_normal() -> typing.Iterator[ComponentInfo]:
"""Walk extensions when not using PyInstaller."""
for _finder, name, ispkg in pkgutil.walk_packages(components.__path__):
for _finder, name, ispkg in pkgutil.walk_packages(
path=components.__path__,
prefix=components.__name__ + '.',
onerror=_walk_error):
if ispkg:
continue
fullname = components.__name__ + '.' + name
yield ComponentInfo(name=fullname)
yield ComponentInfo(name=name)
def _walk_pyinstaller() -> typing.Iterator[ComponentInfo]: