mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
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
76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
# -*- mode: python ; coding: utf-8 -*-
|
|
from os.path import join
|
|
from platform import system
|
|
from PyInstaller.utils.hooks import copy_metadata
|
|
|
|
datas = [('src/interface/web', 'src/interface/web')]
|
|
datas += copy_metadata('tqdm')
|
|
datas += copy_metadata('regex')
|
|
datas += copy_metadata('requests')
|
|
datas += copy_metadata('packaging')
|
|
datas += copy_metadata('filelock')
|
|
datas += copy_metadata('numpy')
|
|
datas += copy_metadata('tokenizers')
|
|
|
|
|
|
block_cipher = None
|
|
|
|
|
|
a = Analysis(
|
|
['src/main.py'],
|
|
pathex=[],
|
|
binaries=[],
|
|
datas=datas,
|
|
hiddenimports=['huggingface_hub.repository'],
|
|
hookspath=[],
|
|
hooksconfig={},
|
|
runtime_hooks=[],
|
|
excludes=[],
|
|
win_no_prefer_redirects=False,
|
|
win_private_assemblies=False,
|
|
cipher=block_cipher,
|
|
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]
|
|
|
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
|
|
|
exe = EXE(
|
|
pyz,
|
|
a.scripts,
|
|
a.binaries,
|
|
a.zipfiles,
|
|
a.datas,
|
|
[],
|
|
name='Khoj',
|
|
debug=False,
|
|
bootloader_ignore_signals=False,
|
|
strip=False,
|
|
upx=True,
|
|
upx_exclude=[],
|
|
runtime_tmpdir=None,
|
|
console=False,
|
|
disable_windowed_traceback=False,
|
|
argv_emulation=False,
|
|
target_arch='x86_64',
|
|
codesign_identity=None,
|
|
entitlements_file=None,
|
|
icon='src/interface/web/assets/icons/favicon.icns',
|
|
)
|
|
|
|
if system() == 'Darwin':
|
|
app = BUNDLE(
|
|
exe,
|
|
name='Khoj.app',
|
|
icon='src/interface/web/assets/icons/favicon.icns',
|
|
bundle_identifier=None,
|
|
)
|