From 7cf345a1386fc30d5ccb16e4229d84c5ca945185 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 17 Aug 2022 22:59:01 +0300 Subject: [PATCH] Exclude unused mac libs under torch/lib. Reduce Mac app size by 30Mb libtorch_cuda only seems to be imported in Linux. Which is why the size of the Mac, Windows apps are 700Mb smaller than the Debian app size. Guessing this is because libtorch_cuda only works on Linux machines? Anyway, removing libtorch_{cpu,python}.dylib under torch/lib from the Mac app reduces it's size from 190Mb to 160Mb. 15% reduction isn't too bad --- Khoj.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Khoj.spec b/Khoj.spec index 7df8b79b..56d164e7 100644 --- a/Khoj.spec +++ b/Khoj.spec @@ -35,7 +35,11 @@ a = Analysis( # Filter out unused, duplicate shared libs under torch/lib torch_lib_path = set([ join('torch', 'lib', 'libtorch_cuda.so'), - join('torch', 'lib', 'libtorch_cpu.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] pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)