BuzzInstaller FIXES
Summary of All Changes
Part 1: PyInstaller _MEI Cleanup Fix (3 files)
Root cause: When BuzzInstaller.exe (PyInstaller onefile) spawns the --background process via subprocess.Popen([sys.executable, "--background"]), the child inherits the _MEIPASS2 environment variable set by the parent's C bootloader. The child's bootloader sees _MEIPASS2 already set and reuses the parent's _MEI* extraction directory instead of extracting its own copy. The background process is intentionally long-lived, keeping Qt DLLs loaded from the parent's _MEI* directory — locking it. When the foreground exits, PyInstaller's cleanup fails.
1. src/BuzzInstaller/system/background_service.py — PRIMARY FIX
- Strips
_MEIPASS2from the child's environment when spawning subprocesses while frozen, forcing the child to extract its own_MEI*directory.
2. src/BuzzInstaller/core/buzzheavier_api.py — NETWORK CLEANUP
- Added
BuzzHeavierAPI.close()to release therequests.Session(connection pools/sockets). - Fixed
get_download_url()to properly close HTTP responses withresp.close()in afinallyblock.
3. src/BuzzInstaller/main.py — SHUTDOWN LOGGING + CLEANUP
run_upload(): Addedservice.api.close()in worker'sfinallyblock, thread join afterapp.exec().run_download(): Addedworker_doneEvent,service.api.close()infinallyblock, thread join.main()background mode: Added shutdown logging aroundsvc.run()andsvc.stop().__main__: Added exit logging.
Part 2: Shortcut Creation (2 new files, 1 modified)
4. src/BuzzInstallerInstaller/shortcut.py — NEW FILE
create_shortcut(exe_path, shortcut_path)— Creates/updates a real.lnkfile using PowerShell's WScript.Shell COM object.delete_shortcut(shortcut_path)— Removes a shortcut.get_shortcut_target(shortcut_path)— Reads the target of an existing shortcut.
5. src/BuzzInstallerInstaller/installer.py — SHORTCUT INTEGRATION
create_shortcut_for_installed()— CreatesC:\BuzzInstaller\BuzzInstaller.lnkafter install/update.delete_buzzinstaller()— Removes the shortcut on delete (only removesC:\BuzzInstallerdir if empty).Installer.run()— Creates shortcut after successful install/update (best-effort, non-fatal on failure).
6. src/BuzzInstallerInstaller/tests/test_shortcut.py — NEW FILE
- 13 tests covering: create, update, target path, working directory, permission failure, delete, missing shortcut, installer integration, unrelated file preservation.
Test Results
- test_version.py: 10/10 PASS
- test_installer.py: 24/24 PASS
- test_improvements.py: 19/19 PASS
- test_shortcut.py: 13/13 PASS
- Total: 66/66 tests PASS
- One-file PyInstaller build: SUCCESS (256 MB executable)