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
This commit is contained in:
Debanjum 2023-07-09 10:21:16 -07:00 committed by GitHub
parent 4c135ea316
commit 77755c0284
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View file

@ -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=[],

View file

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