From 77755c02849d8ca12e1bb9b6ccd685bffd587629 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sun, 9 Jul 2023 10:21:16 -0700 Subject: [PATCH] Fix Packaging the Khoj Desktop Apps (#289) * Add langchain static files and pytorch metadata to Khoj native app * Add pillow static files, metadata & hidden imports to Khoj native app * Fix path to web interface static files on Khoj native app * Add tiktoken hidden imports to make chat work from Khoj native app * Fix Khoj native app to run with GUI mode enabled This got broken when we moved from using the --no-gui flag to using --gui in https://github.com/khoj-ai/khoj/pull/263 --- Khoj.spec | 10 +++++++--- src/khoj/main.py | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Khoj.spec b/Khoj.spec index 7076e0c0..a2d92e29 100644 --- a/Khoj.spec +++ b/Khoj.spec @@ -5,9 +5,12 @@ from PyInstaller.utils.hooks import copy_metadata import sysconfig datas = [ - ('src/khoj/interface/web', 'src/khoj/interface/web'), - (f'{sysconfig.get_paths()["purelib"]}/transformers', 'transformers') + ('src/khoj/interface/web', 'khoj/interface/web'), + (f'{sysconfig.get_paths()["purelib"]}/transformers', 'transformers'), + (f'{sysconfig.get_paths()["purelib"]}/langchain', 'langchain'), + (f'{sysconfig.get_paths()["purelib"]}/PIL', 'PIL') ] +datas += copy_metadata('torch') datas += copy_metadata('tqdm') datas += copy_metadata('regex') datas += copy_metadata('requests') @@ -15,6 +18,7 @@ datas += copy_metadata('packaging') datas += copy_metadata('filelock') datas += copy_metadata('numpy') datas += copy_metadata('tokenizers') +datas += copy_metadata('pillow') block_cipher = None @@ -23,7 +27,7 @@ a = Analysis( pathex=[], binaries=[], datas=datas, - hiddenimports=['huggingface_hub.repository'], + hiddenimports=['huggingface_hub.repository', 'PIL', 'PIL._tkinter_finder', 'tiktoken_ext', 'tiktoken_ext.openai_public'], hookspath=[], hooksconfig={}, runtime_hooks=[], diff --git a/src/khoj/main.py b/src/khoj/main.py index 466d17ff..cc91e705 100644 --- a/src/khoj/main.py +++ b/src/khoj/main.py @@ -172,5 +172,10 @@ class ServerThread(QThread): start_server(self.app, self.host, self.port, self.socket) -if __name__ == "__main__": +def run_gui(): + sys.argv += ["--gui"] run() + + +if __name__ == "__main__": + run_gui()