Ignore already imported Qt module with PyInstaller

Starting with PyInstaller 6.5.0, it imports Qt bindings early, due to
this change: https://github.com/pyinstaller/pyinstaller/pull/8315

We warn about this in order to avoid unintentional early Qt imports in
qutebrowser. However, in the case of using PyInstaller, we just suppress
the warning now, as it's not us to blame.

See https://github.com/qutebrowser/qutebrowser/pull/8123
This commit is contained in:
Florian Bruhin 2024-03-26 13:57:07 +01:00
parent 1ee138b681
commit d37f5b7be0
1 changed files with 2 additions and 2 deletions

View File

@ -168,9 +168,9 @@ def _select_wrapper(args: Optional[argparse.Namespace]) -> SelectionInfo:
- Otherwise, try the wrappers in WRAPPER in order (PyQt6 -> PyQt5)
"""
# If any Qt wrapper has been imported before this, something strange might
# be happening.
# be happening. With PyInstaller, it imports the Qt bindings early.
for name in WRAPPERS:
if name in sys.modules:
if name in sys.modules and not hasattr(sys, "frozen"):
warnings.warn(f"{name} already imported", stacklevel=1)
if args is not None and args.qt_wrapper is not None: