diff --git a/pyproject.toml b/pyproject.toml index 758de2f..4087bda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,8 @@ dependencies = [ "crccheck >= 1.3.0", "pylibfdt >= 1.7.2.post1", "packaging >= 24.2", - "backports.zstd; python_version < '3.14'" + "backports.zstd; python_version < '3.14'", + "libusb; platform_system=='Windows'" ] [project.urls] diff --git a/snagboot.spec b/snagboot.spec index bc83660..6701a1f 100644 --- a/snagboot.spec +++ b/snagboot.spec @@ -3,8 +3,10 @@ # Snagboot spec file, for PyInstaller # -from PyInstaller.utils.hooks import copy_metadata +from PyInstaller.utils.hooks import copy_metadata, collect_dynamic_libs +from PyInstaller.compat import is_win import packaging.requirements +import libusb import os with open("MANIFEST.in", "r") as manifest_file: @@ -65,6 +67,25 @@ snagfactory = Analysis( optimize=0, ) +# Include libusb-1.0.dll from libusb as it is needed by pyusb on windows + +if is_win: + libusbDLL = collect_dynamic_libs( + "libusb", + destdir=".", + search_patterns=['*.dll'], + ) + test = Analysis( + ['src/snagrecover/cli.py'], + binaries = libusbDLL, + ) + for src, dst in libusbDLL: + snagrecover.binaries.extend([( + "libusb-1.0.dll", + src, + "BINARY" + )]) + # Refer to snagrecover analysis for common data files MERGE( @@ -115,4 +136,3 @@ coll = COLLECT( upx=True, name='snagboot', ) -