PyBuild
Compile Python into standalone .exe. No Python needed on target machines.
Features
- Portable mode — bundles Python runtime into a folder, double-click to run
- Single-file mode — one
.exewith everything embedded (Python + stdlib + deps + assets) - Full stdlib collection — collects the entire standard library, zero missing-module errors
- Recursive dependency tracing — auto-discovers transitive third-party dependencies (A → B → C)
- Source protection —
.pycompiled to.pyc, local variable obfuscation, ZIP encryption (SHA-256 stream cipher), anti-debug (IsDebuggerPresent) - Auto asset detection — AST-based scanning for file references in string literals,
os.path.join(),Path(), f-strings - Interactive mode — drag-and-drop or type file paths
pybuild local— pack PyBuild itself into any directory for portable use- Config-driven builds —
pybuild.jsonsupports multiple build targets with per-build settings - Hook system — package-specific collection rules for dynamic imports, hidden modules, and data files (numpy, PIL, pygame, pandas, requests, cryptography, matplotlib, tkinter, sqlalchemy + auto-fallback)
Install
pip install pybuild-exe
Requires Python 3.10+ on Windows. Uses the built-in C# compiler (csc.exe) for launcher PE generation.
Quick Start
pybuild Main.py # portable mode (default, creates Main/Main.exe)
pybuild Main.py --single # single-file Main.exe
pybuild Main.py -o Game --single # single-file Game.exe
pybuild --config # build all targets from pybuild.json
pybuild --config builds.json # build from specified config file
pybuild local # pack PyBuild itself into current directory
Run pybuild with no arguments to enter interactive mode.
CLI Reference
| Command | Description |
|---|---|
pybuild Main.py |
Pack Main.py in portable mode (default) |
pybuild Main.py --single |
Pack Main.py into a single .exe |
pybuild Main.py -o Game |
Set output name to Game |
pybuild Main.py --outpath D:/output |
Set output directory |
pybuild Main.py --icon app.ico |
Embed icon into .exe |
pybuild Main.py --console |
Show console window (hidden by default) |
pybuild --config |
Build from pybuild.json (auto-find) |
pybuild --config builds.json |
Build from specified config |
pybuild local |
Pack PyBuild into current working directory |
pybuild --new |
View changelog |
Config File (pybuild.json)
{
"version": "1.0.0",
"product_name": "MyApp",
"company": "MyCompany",
"description": "My Application",
"builds": [
{
"entry": "main.py",
"output": "MyApp",
"outpath": "D:/release",
"single": true,
"console": false,
"icon": "assets/app.ico",
"assets": ["images", "sounds", "config.json"]
},
{
"entry": "tools/helper.py",
"output": "HelperTool",
"single": false,
"console": true
}
]
}
Config Fields
Top-level (version info, embedded into .exe properties):
| Field | Description |
|---|---|
version |
Version string (e.g. "1.0.0") |
product_name |
Product name, used as output exe name if set |
company |
Company name |
description |
File description |
Per-build:
| Field | Description |
|---|---|
entry |
Entry script path (relative to config file) |
output |
Output exe/folder name (default: entry script name) |
outpath |
Output directory (default: entry script directory) |
single |
true = single-file .exe, false = portable folder (default: false) |
console |
true = show console, false = hide (default: false) |
icon |
Path to .ico file (non-.ico images auto-converted via PIL) |
assets |
List of asset directories and/or files to include |
How It Works
- Collect — scans entry script imports recursively, finds all project
.pyfiles, third-party packages (with transitive deps), and the full standard library - Compile — all
.pyfiles compiled to.pycviacompile(optimize=2), with symbol obfuscation for project source - Encrypt — single-file mode encrypts the ZIP payload with a SHA-256 stream cipher, key embedded in the C# launcher
- Bundle — portable mode copies everything into a folder; single-file mode concatenates PE + encrypted ZIP + config footer
New in 1.15.0
pybuild localcommand — pack PyBuild into any directory for portable use withoutpip install- Full stdlib collection — replaced fragile AST import tracing with complete stdlib walk, eliminating all
No module named Xerrors - Recursive dependency tracing — third-party packages are scanned for their own imports, transitive deps auto-collected
- Self-pack fixes — PyBuild-exe.exe can now correctly build other projects via drag-and-drop (fixed
_pthisolation,find_specfallback, bootstrap naming collision) - Performance — cold-start extraction ~1.6s (was ~7s), cached start ~1s
- Asset support —
collect_assetsnow accepts individual files, not just directories
Contact
Email: 2674675526@qq.com
Bug reports, feature requests, and feedback are welcome.
License
MIT
Metadata
Release files for pybuild-exe 1.15.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pybuild_exe-1.15.5.tar.gz | 92.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pybuild_exe-1.15.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 187.5 kB
Release files / pybuild_exe-1.15.5.tar.gz
| Download URL | pybuild_exe-1.15.5.tar.gz |
|---|---|
| Size | 92.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70edc497ff68f20ee3c26df915e444426c803520284e51c6d6733f69c5715490
|
|
BLAKE2b-256 checksum How to use checksums |
184dbcc01636d4f6ba3c5fc3d261a387e8d50190292c0da9c4767b11d3f07730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / pybuild_exe-1.15.5-py3-none-any.whl
| Download URL | pybuild_exe-1.15.5-py3-none-any.whl |
|---|---|
| Size | 94.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbb2a045a04bcca29677feb352cb0e34ab8c90be58b009566bf08503806d4d7c
|
|
BLAKE2b-256 checksum How to use checksums |
07679d188a03c9bca4f37dc99c7c1f74f3e2e917cf977ff98ddc6d160d2600fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|