qtpyqtpyinstallerpyqt5qwebview

Compiling PyQt5 App with QtWebEngine


I've been trying to compile an app that uses the QtWebEngine from PyQt5. The app works as intended but it fails when compiling. I've spent a couple of days looking for solution but so far I had no luck. I've installed python from both brew and downloading the package form it's website. I've also installed PyQt5 form brew and pip3 without any luck. After running the pyinstaller script I get the "cannot find QtWebEngineProcess" error. That's fixed by copying the QtWebEngineProcess.app file into the MacOS folder. Subsequentially I made sure that the info.plist file is not a symlink but the actual file. Afterwards I added the "org.qt-project.Qt.QtWebEngineCore" flag to the "CFBundleIdentifier" in the main app info.plist. This resolves the problem of not finding "QtWebEngineProcess" but it brings now the error stated below. I copied the "icudtl.dat" to the MacOS folder as well. I also tried rebuilding the dependencies with the framework itself and making sure I don't have symlinks like stated here. I'm not familiar with the install_name_tool so I'm stuck there. Any ideas? Is anyone able to compile a pyqt app using QtWebEngine at all?

Here's the error I'm facing:

[0201/130544:ERROR:icu_util.cc(162)] Invalid file descriptor to ICU data received.
[0201/130544:FATAL:content_main_runner.cc(714)] Check failed: base::i18n::InitializeICU(). 
0   QtWebEngineCore                     0x000000010d4b62e3 _ZN15QtWebEngineCore20FilePickerController11qt_metacallEN11QMetaObject4CallEiPPv + 12132083
1   QtWebEngineCore                     0x000000010d4c9809 _ZN15QtWebEngineCore20FilePickerController11qt_metacallEN11QMetaObject4CallEiPPv + 12211225
2   QtWebEngineCore                     0x000000010ce7cb03 _ZN15QtWebEngineCore20FilePickerController11qt_metacallEN11QMetaObject4CallEiPPv + 5605139
3   QtWebEngineCore                     0x000000010c918ee4 _ZN15QtWebEngineCore18WebContentsAdapter14faviconManagerEv + 28052
4   QtWebEngineCore                     0x000000010c917f48 _ZN15QtWebEngineCore18WebContentsAdapter14faviconManagerEv + 24056
5   QtWebEngineCore                     0x000000010c90e3b9 _ZN15QtWebEngineCore18WebContentsAdapterC2EPN7content11WebContentsE + 57
6   QtWebEngineWidgets                  0x000000011113ce4e _ZrsR11QDataStreamR17QWebEngineHistory + 1870
7   QtWebEngineWidgets                  0x000000011113ec20 _ZN14QWebEnginePageC1EP7QObject + 48
8   QtWebEngineWidgets                  0x000000011114ad17 _ZN14QWebEngineView6setUrlERK4QUrl + 55
9   PyQt5.QtWebEngineWidgets.so         0x0000000111100ca3 _ZL26meth_QWebEngineView_setUrlP7_objectS0_ + 99
10  Python                              0x00000001080faae9 PyCFunction_Call + 233
11  Python                              0x0000000108187a81 PyEval_EvalFrameEx + 35729
12  Python                              0x00000001081884fc PyEval_EvalFrameEx + 38412
13  Python                              0x0000000108188e90 _PyEval_EvalCodeWithName + 2400
14  Python                              0x0000000108188f97 PyEval_EvalCodeEx + 71
15  Python                              0x00000001080d577a function_call + 186
16  Python                              0x00000001080a28d3 PyObject_Call + 99
17  Python                              0x00000001080bd9cc method_call + 140
18  Python                              0x00000001080a28d3 PyObject_Call + 99
19  Python                              0x00000001081184c1 slot_tp_init + 81
20  Python                              0x000000010810ef44 type_call + 212
21  Python                              0x00000001080a28d3 PyObject_Call + 99
22  Python                              0x0000000108182b65 PyEval_EvalFrameEx + 15477
23  Python                              0x0000000108188e90 _PyEval_EvalCodeWithName + 2400
24  Python         

                     0x0000000108188ff1 PyEval_EvalCode + 81
25  Sailor                              0x0000000106e52490 Sailor + 9360
26  Sailor                              0x0000000106e529f9 Sailor + 10745
27  Sailor                              0x0000000106e51464 Sailor + 5220
28  ???                                 0x0000000000000003 0x0 + 3

Trace/BPT trap: 5

Solution

  • It worked for me after using this branch and adding some custom patching:

    def patch_osx_app():
        """Patch .app to copy missing data and link some libs.
        See https://github.com/pyinstaller/pyinstaller/issues/2276
        """
        app_path = os.path.join('dist', 'qutebrowser.app')
        qtwe_core_dir = os.path.join('.tox', 'pyinstaller', 'lib', 'python3.6',
                                     'site-packages', 'PyQt5', 'Qt', 'lib',
                                     'QtWebengineCore.framework')
        # Copy QtWebEngineProcess.app
        proc_app = 'QtWebEngineProcess.app'
        shutil.copytree(os.path.join(qtwe_core_dir, 'Helpers', proc_app),
                        os.path.join(app_path, 'Contents', 'MacOS', proc_app))
        # Copy resources
        for f in glob.glob(os.path.join(qtwe_core_dir, 'Resources', '*')):
            dest = os.path.join(app_path, 'Contents', 'Resources')
            if os.path.isdir(f):
                shutil.copytree(f, os.path.join(dest, f))
            else:
                shutil.copy(f, dest)
        # Link dependencies
        for lib in ['QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtNetwork',
                    'QtGui', 'QtWebChannel', 'QtPositioning']:
            dest = os.path.join(app_path, lib + '.framework', 'Versions', '5')
            os.makedirs(dest)
            os.symlink(os.path.join(os.pardir, os.pardir, os.pardir, 'Contents',
                                    'MacOS', lib),
                       os.path.join(dest, lib))