2022-08-08 21:32:29 +02:00
|
|
|
# -*- mode: python ; coding: utf-8 -*-
|
2022-08-17 21:32:58 +02:00
|
|
|
from os.path import join
|
|
|
|
from platform import system
|
2022-08-08 21:32:29 +02:00
|
|
|
from PyInstaller.utils.hooks import copy_metadata
|
2022-08-19 17:42:49 +02:00
|
|
|
import sysconfig
|
2022-08-08 21:32:29 +02:00
|
|
|
|
2022-08-19 17:42:49 +02:00
|
|
|
datas = [
|
2023-07-09 19:21:16 +02:00
|
|
|
('src/khoj/interface/web', 'khoj/interface/web'),
|
|
|
|
(f'{sysconfig.get_paths()["purelib"]}/transformers', 'transformers'),
|
|
|
|
(f'{sysconfig.get_paths()["purelib"]}/langchain', 'langchain'),
|
2023-07-28 20:54:18 +02:00
|
|
|
(f'{sysconfig.get_paths()["purelib"]}/PIL', 'PIL'),
|
|
|
|
(f'{sysconfig.get_paths()["purelib"]}/gpt4all', 'gpt4all'),
|
2022-08-19 17:42:49 +02:00
|
|
|
]
|
2023-07-09 19:21:16 +02:00
|
|
|
datas += copy_metadata('torch')
|
2022-08-08 21:32:29 +02:00
|
|
|
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')
|
2023-07-09 19:21:16 +02:00
|
|
|
datas += copy_metadata('pillow')
|
2023-07-27 00:45:52 +02:00
|
|
|
datas += copy_metadata('huggingface_hub')
|
|
|
|
datas += copy_metadata('safetensors')
|
|
|
|
datas += copy_metadata('pyyaml')
|
2022-08-08 21:32:29 +02:00
|
|
|
|
|
|
|
block_cipher = None
|
|
|
|
|
|
|
|
a = Analysis(
|
2023-02-14 21:50:51 +01:00
|
|
|
['src/khoj/main.py'],
|
2022-08-08 21:32:29 +02:00
|
|
|
pathex=[],
|
|
|
|
binaries=[],
|
|
|
|
datas=datas,
|
2023-07-09 19:21:16 +02:00
|
|
|
hiddenimports=['huggingface_hub.repository', 'PIL', 'PIL._tkinter_finder', 'tiktoken_ext', 'tiktoken_ext.openai_public'],
|
2022-08-08 21:32:29 +02:00
|
|
|
hookspath=[],
|
|
|
|
hooksconfig={},
|
|
|
|
runtime_hooks=[],
|
|
|
|
excludes=[],
|
|
|
|
win_no_prefer_redirects=False,
|
|
|
|
win_private_assemblies=False,
|
|
|
|
cipher=block_cipher,
|
|
|
|
noarchive=False,
|
|
|
|
)
|
2022-08-17 21:32:58 +02:00
|
|
|
|
2022-08-18 19:54:59 +02:00
|
|
|
# Filter out unused and/or duplicate shared libs
|
2022-08-18 10:25:52 +02:00
|
|
|
torch_lib_paths = {
|
2022-08-18 19:54:59 +02:00
|
|
|
join('torch', 'lib', 'libtorch_cuda.so'),
|
|
|
|
join('torch', 'lib', 'libtorch_cpu.so'),
|
2022-08-18 10:25:52 +02:00
|
|
|
}
|
|
|
|
a.datas = [entry for entry in a.datas if not entry[0] in torch_lib_paths]
|
2022-08-17 21:32:58 +02:00
|
|
|
|
2022-08-20 19:29:33 +02:00
|
|
|
os_path_separator = '\\' if system() == 'Windows' else '/'
|
|
|
|
a.datas = [entry for entry in a.datas if not f'torch{os_path_separator}_C.cp' in entry[0]]
|
|
|
|
a.datas = [entry for entry in a.datas if not f'torch{os_path_separator}_dl.cp' in entry[0]]
|
2022-08-18 19:52:34 +02:00
|
|
|
|
2022-08-08 21:32:29 +02:00
|
|
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
|
|
|
|
2022-08-18 19:50:25 +02:00
|
|
|
if system() != 'Darwin':
|
|
|
|
# Add Splash screen to show on app launch
|
|
|
|
splash = Splash(
|
2023-06-18 17:34:58 +02:00
|
|
|
'src/khoj/interface/web/assets/icons/favicon-128x128.png',
|
2022-08-18 19:50:25 +02:00
|
|
|
binaries=a.binaries,
|
|
|
|
datas=a.datas,
|
2022-08-20 19:32:31 +02:00
|
|
|
text_pos=(10, 160),
|
2022-08-18 19:50:25 +02:00
|
|
|
text_size=12,
|
2022-08-20 19:32:31 +02:00
|
|
|
text_color='black',
|
2022-08-18 19:50:25 +02:00
|
|
|
minify_script=True,
|
|
|
|
always_on_top=True
|
|
|
|
)
|
2022-08-17 21:32:58 +02:00
|
|
|
|
2022-08-18 19:50:25 +02:00
|
|
|
exe = EXE(
|
|
|
|
pyz,
|
|
|
|
a.scripts,
|
|
|
|
a.binaries,
|
|
|
|
a.zipfiles,
|
|
|
|
a.datas,
|
|
|
|
splash,
|
|
|
|
splash.binaries,
|
|
|
|
[],
|
|
|
|
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,
|
2023-06-18 17:34:58 +02:00
|
|
|
icon='src/khoj/interface/web/assets/icons/favicon-128x128.ico',
|
2022-08-18 19:50:25 +02:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
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,
|
2023-02-14 21:50:51 +01:00
|
|
|
icon='src/khoj/interface/web/assets/icons/favicon.icns',
|
2022-08-18 19:50:25 +02:00
|
|
|
)
|
2022-08-17 21:32:58 +02:00
|
|
|
app = BUNDLE(
|
|
|
|
exe,
|
|
|
|
name='Khoj.app',
|
2023-02-14 21:50:51 +01:00
|
|
|
icon='src/khoj/interface/web/assets/icons/favicon.icns',
|
2022-08-17 21:32:58 +02:00
|
|
|
bundle_identifier=None,
|
|
|
|
)
|