From 71dbaa2fd97d5e3d18ff303b75b8d49f25e5e038 Mon Sep 17 00:00:00 2001 From: erik aronesty Date: Wed, 13 Sep 2023 15:34:21 -0400 Subject: [PATCH 1/3] script --- scripts/hook-llama_cpp.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 scripts/hook-llama_cpp.py diff --git a/scripts/hook-llama_cpp.py b/scripts/hook-llama_cpp.py new file mode 100644 index 000000000..6c631ef32 --- /dev/null +++ b/scripts/hook-llama_cpp.py @@ -0,0 +1,24 @@ +# How to use this file +# +# 1. create a folder called "hooks" in your repo +# 2. copy this file there +# 3. add the --additional-hooks-dir flag to your pyinstaller command: +# ex: `pyinstaller --name binary-name --additional-hooks-dir=./hooks entry-point.py` + + +from PyInstaller.utils.hooks import collect_data_files, get_package_paths +import os + +# Get the package path +package_path = get_package_paths('llama_cpp')[0] + +# Collect data files +datas = collect_data_files('llama_cpp') + +# Append the additional .dll or .so file +if os.name == 'nt': # Windows + dll_path = os.path.join(package_path, 'llama_cpp', 'llama.dll') + datas.append((dll_path, 'llama_cpp')) +elif os.name == 'posix': # Linux/Mac + so_path = os.path.join(package_path, 'llama_cpp', 'llama.so') + datas.append((so_path, 'llama_cpp')) From 347ba4ad27c9a470ac20f95b1445f8d35b40738c Mon Sep 17 00:00:00 2001 From: earonesty Date: Wed, 13 Sep 2023 14:00:56 -0700 Subject: [PATCH 2/3] Update hook-llama_cpp.py osx seems to use dylib --- scripts/hook-llama_cpp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/hook-llama_cpp.py b/scripts/hook-llama_cpp.py index 6c631ef32..5b7fcf734 100644 --- a/scripts/hook-llama_cpp.py +++ b/scripts/hook-llama_cpp.py @@ -7,7 +7,7 @@ from PyInstaller.utils.hooks import collect_data_files, get_package_paths -import os +import os, sys # Get the package path package_path = get_package_paths('llama_cpp')[0] @@ -19,6 +19,9 @@ if os.name == 'nt': # Windows dll_path = os.path.join(package_path, 'llama_cpp', 'llama.dll') datas.append((dll_path, 'llama_cpp')) -elif os.name == 'posix': # Linux/Mac +elif sys.platform == 'darwin': # Mac + so_path = os.path.join(package_path, 'llama_cpp', 'llama.dylib') + datas.append((so_path, 'llama_cpp')) +elif os.name == 'posix': # Linux so_path = os.path.join(package_path, 'llama_cpp', 'llama.so') datas.append((so_path, 'llama_cpp')) From 3a9227ceb1ae043bcbd3b1e221b085ea17bc3de6 Mon Sep 17 00:00:00 2001 From: earonesty Date: Thu, 14 Sep 2023 10:34:30 -0700 Subject: [PATCH 3/3] Update hook-llama_cpp.py --- scripts/hook-llama_cpp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/hook-llama_cpp.py b/scripts/hook-llama_cpp.py index 5b7fcf734..8df754205 100644 --- a/scripts/hook-llama_cpp.py +++ b/scripts/hook-llama_cpp.py @@ -23,5 +23,5 @@ so_path = os.path.join(package_path, 'llama_cpp', 'llama.dylib') datas.append((so_path, 'llama_cpp')) elif os.name == 'posix': # Linux - so_path = os.path.join(package_path, 'llama_cpp', 'llama.so') + so_path = os.path.join(package_path, 'llama_cpp', 'libllama.so') datas.append((so_path, 'llama_cpp'))