Add workaround for missing QtCore with PyInstaller

See https://github.com/pyinstaller/pyinstaller/issues/4293
and 0abf8e7363
This commit is contained in:
Florian Bruhin 2019-07-18 14:36:39 +02:00
parent 730018e37e
commit e58aa9c8ae
1 changed files with 14 additions and 0 deletions

View File

@ -29,6 +29,7 @@ try:
except ImportError:
hunter = None
import os
import sys
import faulthandler
import traceback
@ -130,6 +131,18 @@ def init_faulthandler(fileobj=sys.__stderr__):
# pylint: enable=no-member,useless-suppression
def pyinstaller_qt_workaround():
"""Work around PATH issues with PyInstaller.
See https://github.com/pyinstaller/pyinstaller/issues/4293
and https://github.com/gridsync/gridsync/pull/236/commits/0abf8e7363cc8c2a10a0263e6dcceb3be1c07022
"""
if (hasattr(sys, 'frozen') and
hasattr(sys, '_MEIPASS') and
sys.platform == 'win32'):
os.environ['PATH'] += os.pathsep + sys._MEIPASS
def check_pyqt_core():
"""Check if PyQt core is installed."""
try:
@ -288,6 +301,7 @@ def early_init(args):
init_faulthandler()
# Here we check if QtCore is available, and if not, print a message to the
# console or via Tk.
pyinstaller_qt_workaround()
check_pyqt_core()
# Init logging as early as possible
init_log(args)