# Packaging the Backup Client (PyInstaller flow) This guide explains how to transform the PySide6 UI into `BackupClient.exe`, bundle the portable configuration, scheduler helpers, and ship-ready assets. ## 1. Pre-requisites 1. Install Python 3.10+ on the Windows build machine. 2. Create a virtual environment inside `/path/to/projbck/client` and activate it. 3. Install the Python dependencies with `pip install -e .` to grab PySide6, requests, python-dotenv, and PyInstaller. 4. Ensure OpenSSH/rsync/sshpass and the scheduler PowerShell helper already exist inside the client directory (`scheduler/manage_scheduler.ps1`, `config.json`). ## 2. Building the executable 1. Open `cmd.exe` or PowerShell (elevated if you need scheduler permissions). 2. Navigate to the project root: `cd \path\to\projbck`. 3. Run the provided helper script: `client\package_client.bat`. It will: - Invoke PyInstaller with `--onefile`, adding `config.json` to the exe root and the `scheduler` folder under the same directory. - Expect PyInstaller to create `client\dist\BackupClient`. - Call `client\post_build.bat dist\BackupClient` to copy `config.json` and the `scheduler` folder explicitly (in case PyInstaller didn’t preserve them) next to `BackupClient.exe`. 4. Alternatively, if you prefer Bash/WSL, `./client/package_client.sh` performs the same operations. ## 3. What travels with the exe The `dist\BackupClient` directory after running the helper will contain: - `BackupClient.exe`: the packaged PySide6 client. - `config.json`: portable configuration storing server URL, profiles, scheduler flag, and API token state. - `scheduler\manage_scheduler.ps1`: PowerShell helper that creates/removes the Task Scheduler task when the checkbox is toggled. ## 4. Post-build validation 1. Confirm `BackupClient.exe` finds `config.json` next to it; this file must remain writable for the UI to save profiles. 2. Ensure `scheduler/manage_scheduler.ps1` exists relative to the executable at `scheduler/manage_scheduler.ps1` so the scheduler toggle can invoke it. 3. Run `BackupClient.exe` to verify the UI opens, loads the config, and `Esegui backup` works. 4. Toggle the scheduler checkbox to confirm PowerShell can find and execute `manage_scheduler.ps1` (it will create a task such as `BackupClient-` under Task Scheduler). ## 5. Deployment Package the entire `dist\BackupClient` folder. The deployment artifact must keep: - `BackupClient.exe` - `config.json` - `scheduler\manage_scheduler.ps1` - Any optional assets you add later (icons, documentation, etc.) If you automate releases, call `client\package_client.bat` inside your CI/CD script and archive the resulting `dist\BackupClient` directory.