From 9f0dd4a63f083b1566481ce0ca9005ce37fd0c14 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 14 Oct 2023 13:25:54 +1000 Subject: [PATCH] Fix startup failure in macOS bundle Closes #2731 --- qt/aqt/package.py | 6 ++++++ qt/bundle/mac/src/main.rs | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/qt/aqt/package.py b/qt/aqt/package.py index 6bece47d1..ace75ca23 100644 --- a/qt/aqt/package.py +++ b/qt/aqt/package.py @@ -68,6 +68,10 @@ def _patch_certifi() -> None: certifi.where = where +def _fix_protobuf_path() -> None: + sys.path.append(str(Path(sys.prefix) / "../Resources")) + + def packaged_build_setup() -> None: if not getattr(sys, "frozen", False): return @@ -76,6 +80,8 @@ def packaged_build_setup() -> None: if sys.platform == "win32": _fix_pywin32() + elif sys.platform == "darwin": + _fix_protobuf_path() _patch_pkgutil() _patch_certifi() diff --git a/qt/bundle/mac/src/main.rs b/qt/bundle/mac/src/main.rs index 81c9559e6..d0d3bcb49 100644 --- a/qt/bundle/mac/src/main.rs +++ b/qt/bundle/mac/src/main.rs @@ -135,7 +135,10 @@ fn make_app(kind: DistKind, mut plist: plist::Dictionary, stamp: &Utf8Path) -> R let path_str = relative_path.to_str().unwrap(); if path_str.contains("libankihelper") { builder.add_file_macos("libankihelper.dylib", entry)?; - } else if path_str.contains("aqt/data") || path_str.contains("certifi") { + } else if path_str.contains("aqt/data") + || path_str.contains("certifi") + || path_str.contains("google/protobuf") + { builder.add_file_resources(relative_path.strip_prefix("lib").unwrap(), entry)?; } else { if path_str.contains("__pycache__") {