From fc273d360983e54c02523ecaede4ba3e691e52a8 Mon Sep 17 00:00:00 2001 From: Rok Mandeljc Date: Sat, 20 May 2023 17:58:24 +0200 Subject: [PATCH] hookutils: qt: fix QtWebEngineCore helper collection for Homebrew With Homebrew python and Qt, we are collecting the Qt libraries from system-wide installation, into top-level application directory (while preserving the .framework bundle directories). So the extra helper files from QtWebEngineCore.framework bundle need to be collected into QtWebEngineCore.framework directory in top-level application directory instead of the sub-directory in PySide/PyQt package directory. --- PyInstaller/utils/hooks/qt/__init__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/PyInstaller/utils/hooks/qt/__init__.py b/PyInstaller/utils/hooks/qt/__init__.py index 235bc87e457..9915d69ce9b 100644 --- a/PyInstaller/utils/hooks/qt/__init__.py +++ b/PyInstaller/utils/hooks/qt/__init__.py @@ -691,10 +691,18 @@ def collect_qtwebengine_files(self): if is_macos_framework: # macOS .framework bundle - data_path = self.location['DataPath'] - - src_framework_path = os.path.join(data_path, 'lib', 'QtWebEngineCore.framework') - dst_framework_path = os.path.join(rel_data_path, 'lib', 'QtWebEngineCore.framework') + src_framework_path = os.path.join(self.location['LibrariesPath'], 'QtWebEngineCore.framework') + + # If Qt libraries are bundled with the package, collect the .framework bundle into corresponding package's + # subdirectory, because binary dependency analysis will also try to preserve the directory structure. + # However, if we are collecting from system-wide Qt installation (e.g., Homebrew-installed Qt), the binary + # depndency analysis will attempt to re-create .framework bundle in top-level directory, so we need to + # collect the extra files there. + bundled_qt_libs = pathlib.Path(self.package_location) in pathlib.Path(src_framework_path).parents + if bundled_qt_libs: + dst_framework_path = os.path.join(rel_data_path, 'lib', 'QtWebEngineCore.framework') + else: + dst_framework_path = 'QtWebEngineCore.framework' # In top-level directory # Collect files from QtWebEngineCore.framework/Helpers helper_datas = hooks.collect_system_data_files(