Add hook for building linux bin

This commit is contained in:
Stefal 2023-09-21 22:25:39 +02:00
parent a9b4df271c
commit 67926a3e3e
2 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,6 @@
When you want to build a binary with pyinstaller :
Windows :
https://github.com/LeoHsiao1/pyexiv2/issues/87#issuecomment-1728415363
if anyone using windows to use pyinstaller, i found the solution for it, which is the command below.
@ -7,3 +8,6 @@ you need to use --add-binary for your "exiv2.dll" and use --add-data for your "e
pyinstaller --add-binary “C:\Python310\Lib\site-packages\pyexiv2\lib\exiv2.dll;.” --add-data “C:\Python310\Lib\site-packages\pyexiv2\lib\py3.10-win\exiv2api.pyd;.” --onefile ccc.py
Linux :
Edit the python_lib_path variable in hooks/hook-pyexiv2.py
run pyinstaller with this argument : --additional-hooks-dir=hooks

17
hooks/hook-pyexiv2.py Normal file
View File

@ -0,0 +1,17 @@
import sysconfig
from PyInstaller.utils.hooks import collect_data_files
# Collect the required binary files
binaries = []
# Get the system Python library path
python_lib_path = './mly_venv/lib/python3.10/site-packages/'
libexiv2_path = f"{python_lib_path}/pyexiv2/lib/libexiv2.so"
exiv2api_path = f"{python_lib_path}/pyexiv2/lib/py3.10-linux/exiv2api.so"
# Append the binary files and their destination paths to the binaries list
binaries.append((libexiv2_path, "pyexiv2/lib"))
binaries.append((exiv2api_path, "pyexiv2/lib/py3.10-linux"))
# Collect any data files if needed
datas = collect_data_files('pyexiv2')