Skip to content

bunpy build

bunpy build [flags] <script.py>

Description

Compiles a Python script and its imports into a portable .pyz archive. With --compile, cross-compiles to a standalone native binary that does not require bunpy to run.

Flags

FlagDefaultDescription
--outfile, -o<script>.pyzOutput file path
--compileoffCompile to a native binary (embeds the goipy VM)
--target <os-arch>hostCross-compile target: linux-x64, linux-arm64, darwin-x64, darwin-arm64, windows-x64
--minifyoffMinify Python source before bundling
--define <K=V>Replace K with the literal V in source at compile time
--sourcemapoffEmit a .pyz.map source map alongside the bundle
--watchoffRebuild on file changes
--help, -hPrint help

Examples

Bundle to .pyz:

bunpy build app.py
# → app.pyz

Specify output name:

bunpy build -o dist/myapp.pyz app.py

Run the bundle:

bunpy app.pyz
# or, if bunpy is on PATH:
./app.pyz

Compile to a native binary for the current host:

bunpy build --compile app.py -o dist/myapp
./dist/myapp

Cross-compile for Linux x64 from macOS:

bunpy build --compile --target linux-x64 app.py -o dist/myapp-linux

Strip dead branches at compile time with --define:

bunpy build --define DEBUG=False app.py

Watch mode during development:

bunpy build --watch app.py

.pyz format

A .pyz file is a ZIP archive with a __main__.py entry point and a #! shebang pointing to bunpy. It is runnable with bunpy <file>.pyz or, if marked executable, directly as ./myapp.pyz.