# Bag3 Windows exe build (run all commands in this python/ folder)

py -m pip install --upgrade pyinstaller
py -m pip install --upgrade pywin32
py -m pip install --upgrade Pillow "qrcode[pil]" requests

py -m PyInstaller --noconfirm --clean Bag3.spec

# Output: dist\Bag3\Bag3.exe plus dist\Bag3\_internal\...
# Copy the ENTIRE dist\Bag3\ folder to the client PC (not only Bag3.exe).

# --- If the client exe flashes and closes ---

1) On the client PC, open cmd in the Bag3 folder and run:
   Bag3.exe
   You should see the error in the console, or open bag3_startup_error.log next to Bag3.exe.

2) Compare BUILD machines (both should match):
   py --version
   py -m PyInstaller --version
   py -m pip show pyinstaller pywin32 Pillow qrcode requests

   A broken build is often caused by:
   - Different Python major version (e.g. 3.13 vs 3.11)
   - Incomplete tkinter on that Python (Store Python / partial install)
   - Old PyInstaller missing Tcl/Tk files in the bundle

3) Rebuild on the machine that works, or reinstall Python from python.org (64-bit)
   and reinstall deps above, then rebuild.

4) Bag3.spec disables UPX (upx=False) for stability; do not re-enable unless you test on the client.

5) Client needs 64-bit Windows and Microsoft VC++ Redistributable (same as your Python installer).

6) Antivirus may quarantine files under _internal\ — whitelist the Bag3 folder if the log mentions missing DLL.
