build: fix trezor: new trezorlib 0.20 now requires *.dist-info metadata
What changed, and why it matters
This commit fixes a build/packaging problem in Electrum's bundled desktop releases (AppImage, Windows, macOS). A newer version of the Trezor hardware-wallet library now needs its package metadata files to be present, otherwise it cannot report its version and Electum wrongly treats it as incompatible. The change simply includes those metadata files in the bundled app. It is a reliability fix, not a security vulnerability patch.
No security action required; treat as a normal build fix. Users relying on Trezor hardware wallets in bundled Electrum releases should upgrade to a build containing this commit to restore Trezor functionality.
Security signals we found
No security-relevant code change
Build/packaging compatibility fix only
No attacker-controlled input is processed
No memory safety, cryptography, or authorization changes
Evidence from the diff
The commit updates three PyInstaller/AppImage build scripts so that trezor’s *.dist-info metadata is preserved in packaged binaries. trezorlib 0.20 uses importlib.metadata.version(‘trezor’) in getattr, which raises PackageNotFoundError when the dist-info directory is stripped. The fix preserves slip10 and trezor dist-info through the reproducible-build stripping dance in the AppImage script, and adds copy_metadata(‘trezor’) in the Windows and macOS PyInstaller specs. No runtime code logic is changed.
Changed components
contrib/build-linux/appimage/make_appimage.shcontrib/build-wine/pyinstaller.speccontrib/osx/pyinstaller.specInspect captured patch +4 / −2
diff --git a/contrib/build-linux/appimage/make_appimage.sh b/contrib/build-linux/appimage/make_appimage.sh
index 061a12a..f10ef52 100755
--- a/contrib/build-linux/appimage/make_appimage.sh
+++ b/contrib/build-linux/appimage/make_appimage.sh
@@ -245,10 +245,10 @@ rm -rf "$PYDIR"/site-packages/PyQt6/Qt.so
find "$APPDIR" -path '*/__pycache__*' -delete
# although note that *.dist-info might be needed by certain packages...
# e.g. slip10 uses importlib that needs it
-for f in "$PYDIR"/site-packages/slip10-*.dist-info; do mv "$f" "$(echo "$f" | sed s/\.dist-info/\.dist-info2/)"; done
+for f in "$PYDIR"/site-packages/{slip10,trezor}-*.dist-info; do mv "$f" "$(echo "$f" | sed s/\.dist-info/\.dist-info2/)"; done
rm -rf "$PYDIR"/site-packages/*.dist-info/
rm -rf "$PYDIR"/site-packages/*.egg-info/
-for f in "$PYDIR"/site-packages/slip10-*.dist-info2; do mv "$f" "$(echo "$f" | sed s/\.dist-info2/\.dist-info/)"; done
+for f in "$PYDIR"/site-packages/{slip10,trezor}-*.dist-info2; do mv "$f" "$(echo "$f" | sed s/\.dist-info2/\.dist-info/)"; done
find -exec touch -h -d '2000-11-11T11:11:11+00:00' {} +
diff --git a/contrib/build-wine/pyinstaller.spec b/contrib/build-wine/pyinstaller.spec
index 09f1655..91e34b9 100644
--- a/contrib/build-wine/pyinstaller.spec
+++ b/contrib/build-wine/pyinstaller.spec
@@ -51,6 +51,7 @@ datas += collect_data_files('bitbox02')
# some deps rely on importlib metadata
datas += copy_metadata('slip10') # from trezor->slip10
+datas += copy_metadata('trezor')
# Exclude parts of Qt that we never use. Reduces binary size by tens of MBs. see #4815
excludes = [
diff --git a/contrib/osx/pyinstaller.spec b/contrib/osx/pyinstaller.spec
index 6adb551..682807d 100644
--- a/contrib/osx/pyinstaller.spec
+++ b/contrib/osx/pyinstaller.spec
@@ -54,6 +54,7 @@ datas += collect_data_files('bitbox02')
# some deps rely on importlib metadata
datas += copy_metadata('slip10') # from trezor->slip10
+datas += copy_metadata('trezor')
# Exclude parts of Qt that we never use. Reduces binary size by tens of MBs. see #4815
excludes = [
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.