Prepare Build Script¶
The prepare_build.py script automates all preparatory steps needed before building the Pytonium wheel. It syncs C++ sources, copies CEF binaries, and places the subprocess executable into the correct directory structure.
Overview¶
The script performs these steps in order:
- Clean -- Removes old build artifacts (
dist/,_skbuild/,Pytonium.egg-info/,bin_win/orbin_linux/) - Sync C++ sources -- Copies library and subprocess source files into the pyframework directory
- Copy CEF binaries -- Copies headers, cmake modules, libcef_dll wrapper, and libcef
- Copy CEF resources -- Copies runtime resources and shared libraries to the bin folder
- Copy subprocess -- Places the
pytonium_subprocessexecutable in the bin folder - Strip symbols (Linux only) -- Strips debug symbols from
.sofiles (e.g.,libcef.so1.5 GB -> ~250 MB)
Prerequisites¶
Before running the script
- Python 3.10+ virtual environment activated
- CEF binaries downloaded in
cef-binaries-windows/orcef-binaries-linux/ - C++ library source in
src/pytonium_library/ - Subprocess source in
src/pytonium_subprocess/ - Subprocess executable built (see Subprocess Build)
Basic Usage¶
Full Preparation (All Platforms)¶
This prepares both Windows and Linux binaries.
Windows Only¶
Linux Only¶
CLI Options¶
| Option | Description | Default |
|---|---|---|
--platform {windows,linux,all} | Which platform to prepare | all |
--build-dir PATH | CMake build directory to locate pytonium_subprocess | (auto-detect) |
--dry-run | Show what would be done without making changes | off |
-v, --verbose | Enable verbose output | off |
--skip-clean | Skip the cleanup step | off |
--skip-sync | Skip C++ source sync step | off |
--skip-cef | Skip CEF binary copy step | off |
Examples¶
Dry Run¶
Preview what the script will do without making any changes:
Use dry run first
When running the script for the first time or after changing your build setup, a dry run lets you verify the paths and steps before any files are modified.
Verbose Output¶
See detailed progress during execution:
Windows Preparation with Custom Build Directory¶
Skip Specific Steps¶
If you have already completed certain steps, you can skip them:
# Skip cleanup if files already removed
python prepare_build.py --skip-clean
# Only copy CEF binaries (skip cleanup and sync)
python prepare_build.py --skip-clean --skip-sync
# Only sync sources (skip cleanup and CEF copy)
python prepare_build.py --skip-clean --skip-cef
Complete Build Workflow¶
Step 1: Prepare the Build¶
Step 2: Build the Wheel¶
Step 3: Install the Wheel¶
Troubleshooting¶
"Source library not found"¶
Fix
Ensure src/pytonium_library/ exists in the project root. This directory contains the C++ source files that are synced into the pyframework directory.
"CEF binaries not found"¶
Fix
Ensure cef-binaries-windows/ or cef-binaries-linux/ exists in the project root. These directories contain the CEF binary distribution.
"pytonium_subprocess not found"¶
The subprocess executable must be built separately before running this script.
Fix
Build the subprocess first (see Subprocess Build), then use --build-dir to point at your CMake build directory:
The script searches for the executable in these locations:
- The
--build-dirpath (if provided) src/pytonium_library_test/release/bin/pytonium_subprocess.exe(Windows)src/pytonium_library_test/release/pytonium_subprocess(Linux)
Script Location¶
Run it from the building_pythonium_core directory or adjust paths accordingly.
Quick Reference¶
cd building_pythonium_core
python prepare_build.py # Full prepare (all platforms)
python prepare_build.py --platform windows # Windows only
python prepare_build.py --platform linux # Linux only
python prepare_build.py --dry-run # Show what would be done
python prepare_build.py -v # Verbose output
python prepare_build.py --skip-clean # Skip cleanup
python prepare_build.py --build-dir ../my-build # Custom build directory
See Also¶
- Build Guide -- Complete build-from-source workflow
- Subprocess Build -- How to build the
pytonium_subprocessexecutable