Reduce Windows App Size by Removing Unused Libraries under Torch/Lib

Tighten the duplicate library removal code in Khoj.spec
This commit is contained in:
Debanjum Singh Solanky 2022-08-18 11:25:52 +03:00
parent b78ee317ae
commit 082fe937b9

View file

@ -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)