Add components to pyinstaller hiddenimports
This commit is contained in:
parent
fcb39c1d7f
commit
15e9127fa0
@ -6,6 +6,8 @@ import os
|
|||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
from scripts import setupcommon
|
from scripts import setupcommon
|
||||||
|
|
||||||
|
from qutebrowser.extensions import loader
|
||||||
|
|
||||||
block_cipher = None
|
block_cipher = None
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +29,13 @@ def get_data_files():
|
|||||||
return data_files
|
return 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)
|
||||||
|
return imports
|
||||||
|
|
||||||
|
|
||||||
setupcommon.write_git_file()
|
setupcommon.write_git_file()
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +51,7 @@ a = Analysis(['../qutebrowser/__main__.py'],
|
|||||||
pathex=['misc'],
|
pathex=['misc'],
|
||||||
binaries=None,
|
binaries=None,
|
||||||
datas=get_data_files(),
|
datas=get_data_files(),
|
||||||
hiddenimports=['PyQt5.QtOpenGL', 'PyQt5._QOpenGLFunctions_2_0'],
|
hiddenimports=get_hidden_imports(),
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
excludes=['tkinter'],
|
excludes=['tkinter'],
|
||||||
|
@ -22,22 +22,37 @@
|
|||||||
import importlib.abc
|
import importlib.abc
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import types
|
import types
|
||||||
|
import typing
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
from qutebrowser import components
|
from qutebrowser import components
|
||||||
from qutebrowser.utils import log
|
from qutebrowser.utils import log
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s
|
||||||
|
class ComponentInfo:
|
||||||
|
|
||||||
|
name = attr.ib() # type: str
|
||||||
|
finder = attr.ib() # type: importlib.abc.PathEntryFinder
|
||||||
|
|
||||||
|
|
||||||
def load_components() -> None:
|
def load_components() -> None:
|
||||||
"""Load everything from qutebrowser.components."""
|
"""Load everything from qutebrowser.components."""
|
||||||
|
for info in walk_components():
|
||||||
|
_load_component(info)
|
||||||
|
|
||||||
|
|
||||||
|
def walk_components() -> typing.Iterator[ComponentInfo]:
|
||||||
|
"""Yield ComponentInfo objects for all modules."""
|
||||||
for finder, name, ispkg in pkgutil.walk_packages(components.__path__):
|
for finder, name, ispkg in pkgutil.walk_packages(components.__path__):
|
||||||
if ispkg:
|
if ispkg:
|
||||||
continue
|
continue
|
||||||
_load_module(finder, name)
|
yield ComponentInfo(name=name, finder=finder)
|
||||||
|
|
||||||
|
|
||||||
def _load_module(finder: importlib.abc.PathEntryFinder,
|
def _load_component(info: ComponentInfo) -> types.ModuleType:
|
||||||
name: str) -> types.ModuleType:
|
log.extensions.debug("Importing {}".format(info.name))
|
||||||
log.extensions.debug("Importing {}".format(name))
|
loader = info.finder.find_module(info.name)
|
||||||
loader = finder.find_module(name)
|
|
||||||
assert loader is not None
|
assert loader is not None
|
||||||
return loader.load_module(name)
|
return loader.load_module(info.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user