From 9b7f2e1d69f2742f133aa734e9288aa4ebfa60be Mon Sep 17 00:00:00 2001 From: jknapp Date: Sun, 28 Dec 2025 19:32:23 -0800 Subject: [PATCH] Fix enum34 error by excluding it in PyInstaller spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous approach of uninstalling enum34 before PyInstaller didn't work because 'uv run' re-syncs dependencies. The proper solution is to exclude enum34 directly in the PyInstaller spec file. Changes: - Added hooks/hook-enum34.py: Custom PyInstaller hook to exclude enum34 - Updated local-transcription.spec: - Added 'hooks' to hookspath - Added 'enum34' to excludes list - Updated build.sh and build.bat: - Removed enum34 uninstall step (no longer needed) - Added comment explaining enum34 is excluded in spec Why this works: - PyInstaller's excludes list prevents enum34 from being bundled - The custom hook provides documentation and explicit exclusion - enum34 can remain installed in venv (won't break anything) - Works regardless of 'uv run' re-syncing dependencies enum34 is an obsolete Python 2.7/3.3 backport that's incompatible with PyInstaller and unnecessary on Python 3.4+ (enum is in stdlib). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- build.bat | 5 +---- build.sh | 5 +---- hooks/hook-enum34.py | 10 ++++++++++ local-transcription.spec | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 hooks/hook-enum34.py diff --git a/build.bat b/build.bat index 80c5268..62abeb3 100644 --- a/build.bat +++ b/build.bat @@ -16,11 +16,8 @@ REM Sync dependencies (uses PyTorch CUDA from pyproject.toml) echo Installing dependencies with CUDA support... uv sync -REM Remove enum34 if present (incompatible with PyInstaller) -echo Removing enum34 (if present)... -uv pip uninstall -q enum34 2>nul - REM Build with PyInstaller +REM Note: enum34 is excluded in local-transcription.spec echo Running PyInstaller... uv run pyinstaller local-transcription.spec diff --git a/build.sh b/build.sh index eaba74f..3209de5 100755 --- a/build.sh +++ b/build.sh @@ -15,11 +15,8 @@ rm -rf build dist echo "Installing dependencies with CUDA support..." uv sync -# Remove enum34 if present (incompatible with PyInstaller) -echo "Removing enum34 (if present)..." -uv pip uninstall -q enum34 2>/dev/null || true - # Build with PyInstaller +# Note: enum34 is excluded in local-transcription.spec echo "Running PyInstaller..." uv run pyinstaller local-transcription.spec diff --git a/hooks/hook-enum34.py b/hooks/hook-enum34.py new file mode 100644 index 0000000..13d3075 --- /dev/null +++ b/hooks/hook-enum34.py @@ -0,0 +1,10 @@ +""" +PyInstaller hook to exclude enum34. + +enum34 is an obsolete backport of Python's enum module for Python 2.7 and 3.3. +It is incompatible with Python 3.4+ and PyInstaller. +Since we require Python 3.9+, enum is part of the stdlib and enum34 is not needed. +""" + +# Exclude enum34 completely from the build +excludedimports = ['enum34'] diff --git a/local-transcription.spec b/local-transcription.spec index dd48df5..f875afb 100644 --- a/local-transcription.spec +++ b/local-transcription.spec @@ -129,10 +129,10 @@ a = Analysis( binaries=binaries, datas=datas, hiddenimports=hiddenimports, - hookspath=[], + hookspath=['hooks'], # Add hooks directory for custom PyInstaller hooks hooksconfig={}, runtime_hooks=[], - excludes=[], + excludes=['enum34'], # Exclude enum34 - incompatible with PyInstaller and Python 3.4+ win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher,