-
Notifications
You must be signed in to change notification settings - Fork 10
Building the Executable
ProGRESS can be packaged as a standalone desktop application using PyInstaller. The pre-built executable bundles GLPK for dispatch optimization and HiGHS for PCM. To include additional solvers such as CBC, CPLEX, or Gurobi, you must rebuild the executable on your own machine.
The default progress.spec file locates and bundles the GLPK solver binary (glpsol) and its required libraries. Other solvers are not included in the default build. When you install a new solver on your system, PyInstaller must re-run to detect it and embed it in the executable.
| Requirement | macOS | Windows |
|---|---|---|
| Python environment | Python 3.11+ with ProGRESS dependencies | Python 3.11+ with ProGRESS dependencies |
| PyInstaller | pip install pyinstaller |
pip install pyinstaller |
| GLPK | brew install glpk |
Install winglpk and add to PATH |
| CBC (optional) | brew install cbc |
Install COIN-OR and add to PATH |
| CPLEX (optional) | Install IBM ILOG CPLEX and activate the Python API | Install IBM ILOG CPLEX and activate the Python API |
| Gurobi (optional) | Install Gurobi and pip install gurobipy
|
Install Gurobi and pip install gurobipy
|
Before rebuilding, confirm that each solver is available on your system PATH:
# GLPK (required)
which glpsol
glpsol --version
# CBC (optional)
which cbc
cbc -version
# CPLEX (optional) — verify the Python API is importable
python -c "import cplex; print(cplex.__version__)"
# Gurobi (optional) — verify the Python API is importable
python -c "import gurobipy; print(gurobipy.gurobi.version())"If which cbc does not return a path, add the CBC binary directory to your PATH before rebuilding.
From the repository root, run:
pyinstaller progress.spec --clean -yThe --clean flag forces PyInstaller to discard cached files and re-analyze all imports and binaries. The -y flag overwrites any previous build output without prompting.
The build output is placed in the dist/snl-progress directory:
-
macOS:
dist/snl-progress/snl-progress.app -
Windows:
dist/snl-progress/snl-progress.exe
The spec file controls what PyInstaller bundles:
-
GLPK detection: The spec file calls
shutil.which("glpsol")to locate the GLPK binary. On macOS it also resolves Homebrew-linked shared libraries usingotool -L. On Windows it collects.dllfiles from the GLPK directory. - Binary collection: Collected binaries (GLPK, casadi, pybamm) are embedded in the executable alongside all Python packages.
-
Runtime hook: At launch, the executable runs
hooks/runtime_hook_casadi.py, which adds the bundledglpk/andcasadi/directories to the system PATH so the embedded binaries are discoverable.
To bundle CBC, CPLEX, or Gurobi in the executable, modify progress.spec to detect and collect those solver binaries. For example, to add CBC:
# After the glpk_binaries block, add:
cbc_binaries = []
cbc_path = shutil.which("cbc")
if cbc_path:
cbc_binaries.append((cbc_path, "cbc"))Then add cbc_binaries to the binaries= list in the Analysis call.
For CPLEX and Gurobi, the solvers are typically invoked through their Python APIs (cplex and gurobipy) rather than standalone binaries. These packages are usually included automatically by PyInstaller's import analysis. If they are not detected, add them to the hiddenimports list.
If you bundle additional solver binaries, update hooks/runtime_hook_casadi.py to add their directories to the PATH at runtime. For example:
cbc_dir = os.path.join(bundle_dir, "cbc")
if os.path.isdir(cbc_dir):
path = os.environ.get("PATH", "")
if cbc_dir not in path:
os.environ["PATH"] = cbc_dir + os.pathsep + pathAfter building, verify the executable launches and can find the bundled solver:
- Launch the executable (
snl-progress.appon macOS,snl-progress.exeon Windows). - Open the Simulation page.
- Confirm the dispatch solver dropdown shows the expected options.
- Run a short simulation (1 sample, 24 hours) to verify the solver is invoked.
For command-line verification, you can also inspect the bundled files:
# macOS
ls dist/snl-progress/snl-progress.app/Contents/Resources/glpk/
# Windows
dir dist\snl-progress\_internal\glpk\Next: Additional Features — Degradation models, PCM integration, and multi-period optimization.