From 5c9cf2f8663de647d9ce1a85cdefdd21eb0d7f52 Mon Sep 17 00:00:00 2001
From: Romain Boman <romain.boman@gmail.com>
Date: Thu, 8 Aug 2024 15:09:06 +0200
Subject: [PATCH] fix installer

---
 fossils-win.spec | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/fossils-win.spec b/fossils-win.spec
index 3862edb..4884ff9 100644
--- a/fossils-win.spec
+++ b/fossils-win.spec
@@ -2,7 +2,7 @@
 
 # BUILD DIST:
 #   load environment
-#   pyinstaller --noconfirm fossils.spec
+#   pyinstaller --noconfirm fossils-win.spec
 
 block_cipher = None
 
@@ -63,13 +63,29 @@ exe = EXE(
     entitlements_file=None,
     icon='gui/icons/fossils.ico',
 )
-coll = COLLECT(
-    exe,
-    a.binaries,
-    a.zipfiles,
-    a.datas,
-    strip=False,
-    upx=False, # works well but slower runtime
-    upx_exclude=[],
-    name='fossils',
-)
+
+# when using VBox + mesa drivers installed on c:\Python310\python.exe, 
+# mesa dlls are copied into the installer which makes
+# gmsh display crash at runtime.
+# => we manually remove the libraries related to openGL (they are not present when built outside a vbox)
+# see https://stackoverflow.com/questions/58097858/how-to-exclude-opengl32sw-dll-from-pyqt5-library-when-using-pyinstaller
+to_keep = []
+to_exclude = {'opengl32.dll', 'libglapi.dll', 'libgallium_wgl.dll'}
+for (dest, source, kind) in a.binaries:
+    if os.path.split(dest)[1].lower() in to_exclude:
+        print(f'removing {source}')
+        continue
+    to_keep.append((dest, source, kind))
+a.binaries = to_keep
+
+if 1:
+    coll = COLLECT(
+        exe,
+        a.binaries,
+        a.zipfiles,
+        a.datas,
+        strip=False,
+        upx=False, # works well but slower runtime
+        upx_exclude=[],
+        name='fossils',
+    )
-- 
GitLab