From 67926a3e3e2ff39543033b0f31ecb5ec5d4ca7c6 Mon Sep 17 00:00:00 2001 From: Stefal Date: Thu, 21 Sep 2023 22:25:39 +0200 Subject: [PATCH] Add hook for building linux bin --- for_futur_me.txt | 4 ++++ hooks/hook-pyexiv2.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 hooks/hook-pyexiv2.py diff --git a/for_futur_me.txt b/for_futur_me.txt index 3aa1407..9269327 100644 --- a/for_futur_me.txt +++ b/for_futur_me.txt @@ -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 \ No newline at end of file diff --git a/hooks/hook-pyexiv2.py b/hooks/hook-pyexiv2.py new file mode 100644 index 0000000..d594ac7 --- /dev/null +++ b/hooks/hook-pyexiv2.py @@ -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')