From 082fe937b9d42ef4ba57766028597e658eb1f388 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 18 Aug 2022 11:25:52 +0300 Subject: [PATCH] Reduce Windows App Size by Removing Unused Libraries under Torch/Lib Tighten the duplicate library removal code in Khoj.spec --- Khoj.spec | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Khoj.spec b/Khoj.spec index 56d164e7..e7c7c1f9 100644 --- a/Khoj.spec +++ b/Khoj.spec @@ -32,15 +32,14 @@ a = Analysis( noarchive=False, ) -# Filter out unused, duplicate shared libs under torch/lib -torch_lib_path = set([ - join('torch', 'lib', 'libtorch_cuda.so'), - join('torch', 'lib', 'libtorch_cuda.dylib'), - join('torch', 'lib', 'libtorch_cpu.so'), - join('torch', 'lib', 'libtorch_cpu.dylib'), - join('torch', 'lib', 'libtorch_python.so'), - join('torch', 'lib', 'libtorch_python.dylib')]) -a.datas = [entry for entry in a.datas if not entry[0] in torch_lib_path] +# Filter out unused, duplicate shared libs +extension = {'Windows': '.dll', 'Darwin': '.dylib', 'Linux': '.so'}[system()] +torch_lib_paths = { + join('torch', 'lib', 'libtorch_cuda' + extension), + join('torch', 'lib', 'libtorch_cpu' + extension), + join('torch', 'lib', 'libtorch_python' + extension) +} +a.datas = [entry for entry in a.datas if not entry[0] in torch_lib_paths] pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)