8000 pyinstaller hook script by earonesty · Pull Request #709 · abetlen/llama-cpp-python · GitHub
[go: up one dir, main page]

Skip to content

pyinstaller hook script #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions scripts/hook-llama_cpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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, sys

# 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 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', 'libllama.so')
datas.append((so_path, 'llama_cpp'))
0