This document explains how to build a self-contained executable of the Python GUI Menu application that doesn't require virtual environments or Python installations on the target system.
The build process uses PyInstaller to create a standalone executable that bundles all Python dependencies and includes the necessary configuration and asset files (icons, logos, config.yml).
- Python 3.8 or later
- pip package manager
- Internet connection (for downloading PyInstaller and dependencies)
You have three ways to build the application:
# Make sure you have the requirements file
python build.pyThis is the most portable option that works on Windows, macOS, and Linux.
# Make executable (if needed)
chmod +x build.sh
# Run the build
./build.shbuild.batAll build scripts perform the following steps:
- Prerequisites Check: Verify Python and pip are installed
- Clean Previous Builds: Remove old build artifacts
- Create Build Environment: Set up a temporary virtual environment
- Install Dependencies: Install PyInstaller, PyQt5, and PyYAML
- Verify Assets: Check that required files exist (menu.py, config.yml, logos)
- Create PyInstaller Spec: Generate a detailed build specification
- Build Executable: Run PyInstaller to create the standalone executable
- Create Distribution Package: Bundle executable with assets and documentation
- Create Archive: Generate a ZIP file for easy distribution
- Cleanup: Remove temporary build files
After a successful build, you'll get:
-
Distribution Directory:
menu_YYYYMMDD_HHMMSS/menu(ormenu.exeon Windows) - The standalone executableconfig.yml- Current configurationconfig_sample.yml- Sample configuration for reference- Asset files (logo.png, smallicon.png, greeting.sh if present)
README.txt- Instructions for end usersrun.sh(Unix) orrun.bat(Windows) - Convenience launcher
-
Compressed Archive:
menu_YYYYMMDD_HHMMSS.zip
To include additional files in the executable package, modify the data_files list in the PyInstaller spec file creation section:
data_files = [
('config.yml', '.'),
('logo.png', '.'),
('smallicon.png', '.'),
('my_custom_file.txt', '.'), # Add your file here
]Modify the name parameter in the PyInstaller specification:
exe = EXE(
# ... other parameters ...
name='my_custom_menu', # Change this
# ... rest of parameters ...
)The build creates a GUI application (no console window). To enable console output for debugging:
exe = EXE(
# ... other parameters ...
console=True, # Change to True for console mode
# ... rest of parameters ...
)-
PyInstaller fails with import errors:
- Add missing modules to the
hiddenimportslist in the spec file - Check that all dependencies are installed in the build environment
- Add missing modules to the
-
Assets not found at runtime:
- Verify files are listed in the
data_filessection - Check file paths are correct (relative to the script directory)
- Verify files are listed in the
-
Large executable size:
- PyInstaller bundles all dependencies, resulting in ~100-200MB executables
- This is normal for PyQt5 applications
-
Permission denied errors (Unix/Linux/macOS):
- Make sure the build script is executable:
chmod +x build.sh - Ensure you have write permissions in the build directory
- Make sure the build script is executable:
-
Antivirus false positives:
- Some antivirus software may flag PyInstaller executables
- This is a known issue with packaged Python applications
- Whitelist the executable or build directory if necessary
The build process requires these Python packages (automatically installed):
PyInstaller>=6.0.0- Creates the standalone executablePyQt5>=5.15.0- GUI framework (must match your development version)PyYAML>=6.0- YAML configuration file parsing
Windows:
- Builds create
.exefiles - May trigger Windows Defender SmartScreen on first run
- Include
run.batfor easy launching
macOS:
- May require code signing for distribution
- Users might need to allow unsigned applications in Security preferences
- Executable will be larger due to Qt frameworks
Linux:
- Built executable should work on most Linux distributions
- May have issues with different glibc versions on very old systems
- Include
run.shfor easy launching
To distribute your application:
- For single users: Share the entire distribution directory
- For multiple users: Share the ZIP archive
- For web distribution: Upload the ZIP file to your website/GitHub releases
Include these instructions for your users:
- Download and extract the ZIP file
- Run the executable directly (no installation required)
- Modify
config.ymlto customize the menu - Use
run.sh(Unix) orrun.bat(Windows) for convenience
The application will look for configuration files in this order:
- Command line argument:
./menu my_config.yml - Default:
config.ymlin the same directory as the executable
Development: Use virtual environments and run python menu.py
Production: Use the built executable for end-user distribution
The build process creates completely self-contained applications that work without Python installations, making them ideal for distribution to non-technical users.