Skip to main content

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 .exe with 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 — .py compiled 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.json supports multiple build targets with per-build settings

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

  1. Collect — scans entry script imports recursively, finds all project .py files, third-party packages (with transitive deps), and the full standard library
  2. Compile — all .py files compiled to .pyc via compile(optimize=2), with symbol obfuscation for project source
  3. Encrypt — single-file mode encrypts the ZIP payload with a SHA-256 stream cipher, key embedded in the C# launcher
  4. Bundle — portable mode copies everything into a folder; single-file mode concatenates PE + encrypted ZIP + config footer

New in 1.15.0

  • pybuild local command — pack PyBuild into any directory for portable use without pip install
  • Full stdlib collection — replaced fragile AST import tracing with complete stdlib walk, eliminating all No module named X errors
  • 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 _pth isolation, find_spec fallback, bootstrap naming collision)
  • Performance — cold-start extraction ~1.6s (was ~7s), cached start ~1s
  • Asset support — collect_assets now accepts individual files, not just directories

License

MIT

Metadata

Release files for pybuild-exe 1.15.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybuild-exe 1.15.0
File Size Uploaded
pybuild_exe-1.15.0.tar.gz 80.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybuild-exe 1.15.0
File Interpreter ABI Platform
pybuild_exe-1.15.0-py3-none-any.whl Python 3 none any Details

Total release size: 160.5 kB

Release files / pybuild_exe-1.15.0.tar.gz

Download URL pybuild_exe-1.15.0.tar.gz
Size 80.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6b4a891079eca2aae672e7c3d377148db335275ca8e8618c99f10c88fa349615
BLAKE2b-256 checksum
How to use checksums
64de0d8aa8df7870862afc37c8c20b4431fa625143ef9f3e89e1529cd80bf052
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.0-py3-none-any.whl

Download URL pybuild_exe-1.15.0-py3-none-any.whl
Size 80.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d1a58fea0fbb5bc2e4b9d0b73e14bb354d0be1dd417ab2366e139bf8bb5c5a7
BLAKE2b-256 checksum
How to use checksums
452aceabe6dc940ec58e8fc5fa3124ab64846187bc264f09c7b9002166f8878d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

1.15.5

2 release files

1.15.4

1 release file

1.15.3

1 release file

This release

1.15.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page