# Building Path of Python - Windows Executable
This document explains how to build Path of Python into a standalone Windows executable.
# Quick Start
-
Install PyInstaller (if not already installed):
pip install pyinstaller -
Run the build script:
build.bat -
Find your executable:
- Location:
dist/PathOfPython.exe - This is a single-file executable with all resources bundled
- Location:
# How It Works
# Architecture Overview
The build system uses three key components:
utility/resource_path.py- Detects if running bundled or in dev modepath_of_python.spec- PyInstaller configuration that bundles everythingbuild.bat- Automated build script
# What Gets Bundled
The executable includes:
- ✅ All Python code (core, ui, entities, combat, etc.)
- ✅ All graphics assets (sprites, tiles, UI elements)
- ✅ All data files (JSON configs, quests, scenes)
- ✅ All audio files (music, sound effects)
- ✅ Python runtime and dependencies (pygame, etc.)
# Why It Works Now
Previous issues you likely encountered:
- “Module not found” errors → Fixed by explicit
hiddenimportslist in spec file - “File not found” errors → Fixed by bundling all data directories
- Dynamic imports failing → Fixed by explicitly listing all scene modules
- Wrong file paths → Would be fixed by using
resource_path()helper (optional)
Current approach:
- NO changes needed to game logic
- PyInstaller spec file handles all the complexity
- All resources are bundled and accessible
# Advanced Options
# Console vs Windowed Mode
In path_of_python.spec, find this line:
console=False, # Set to True for debugging, False for release
console=True- Shows console window (useful for debugging build issues)console=False- No console window (clean for distribution)
# Adding an Icon
- Create or obtain a
.icofile - In
path_of_python.spec, change:
to:icon=None, # Add icon='path/to/icon.ico' if you have oneicon='graphics/icon.ico', # or wherever your icon is
# Reducing File Size
The exe might be large (~200-400 MB) due to pygame and dependencies. To reduce:
-
Enable UPX compression (already enabled):
upx=True, -
Exclude unnecessary packages (already configured):
excludes=['tests', 'matplotlib', 'tkinter', ...] -
Use one-folder mode (instead of one-file) - faster but less portable: In spec file, change
EXE()to not include all data in one file
# Troubleshooting
# “Module not found” errors when running exe
Solution: Add the missing module to hiddenimports in path_of_python.spec
Example:
hiddenimports = [
# ... existing imports ...
'your.missing.module',
]
# “File not found” errors for resources
Solution: Add the directory to data_files in path_of_python.spec
Example:
data_files = [
# ... existing files ...
('new_folder', 'new_folder'),
]
# Executable is too large
Solutions:
- Remove unused asset files before building
- Compress audio files (use .ogg instead of .wav)
- Use one-folder distribution instead of one-file
- Remove unused dependencies
# Game works in dev but crashes when bundled
Debugging steps:
- Build with
console=Truein spec file to see error messages - Check that all resources are being bundled
- Verify no absolute paths are hardcoded in game code
- Test on a clean Windows install (or VM without Python)
# Distribution
Once built, you can distribute:
Option 1: Single File (default)
- Just share
dist/PathOfPython.exe - Users run the exe, no installation needed
- Resources are extracted to temp folder on launch
Option 2: One Folder (if modified to do so)
- Share the entire
dist/folder - Users run
PathOfPython.exefrom the folder - Faster startup, but more files to distribute
Recommended: Add a README.txt explaining:
- System requirements (Windows 10/11, DirectX)
- How to run (just double-click the exe)
- Known issues or controls
# Future Development
When adding new features:
- New Python files - PyInstaller will auto-detect most imports
- New dynamically-loaded modules - Add to
hiddenimportsin spec - New asset folders - Add to
data_filesin spec - New dependencies - Install them, PyInstaller will bundle automatically
To rebuild after changes:
build.bat
That’s it! The build system is set up for easy iteration.