Skip to main content

Build a minimal, bespoke CPython runtime from source with size reduction, static linking, and a zipped standard library.

Project description

buildpy-bundler

A lightweight, single-file Python build tool for compiling Python 3.11-3.14 from source with customizable configurations.

Features

  • Single-file script with no external dependencies (stdlib only)
  • Multiple build configurations (static, shared, framework)
  • Automatic dependency building (OpenSSL, bzip2, xz)
  • Size optimization options (stdlib zipping, selective module inclusion)
  • Cross-platform support (macOS, Linux, Windows)

Requirements

  • Python 3.10+ (to run the build script)
  • System tools: git, wget, tar, make
  • C compiler (gcc/clang)

Quick Start

# Build with default configuration (shared_mid)
buildpy build

# Or use make
make

The built Python will be installed to ./build/install/python/.

Usage

buildpy [options] build

Options

Option Description
-v, --version VERSION Python version to build (default: 3.13)
-c, --config NAME Build configuration (default: shared_mid)
-t, --type TYPE Build type: static, shared, or framework
-j, --jobs N Number of parallel build jobs (default: 4)
-o, --optimize Enable PGO/LTO optimization during build
-d, --debug Build debug Python
-p, --precompile Precompile stdlib to bytecode
-m, --package Package the build for distribution
-r, --reset Clean and reset build directory
--install-dir DIR Custom installation directory
-i, --install PKG [PKG ...] Install packages after build
-w, --write Write Setup.local configuration
-s, --json Export configuration to JSON

Examples

# Build Python 3.12 with static linking
buildpy -v 3.12 -t static build

# Build optimized Python with 8 parallel jobs
buildpy -o -j 8 build

# Build and package for distribution
buildpy -m build

# Build to custom directory
buildpy --install-dir /opt/python build

Configurations

Configurations follow the naming pattern <build-type>_<size-type>:

Size Type Description
max Maximum modules included
mid Balanced selection (recommended)
min Minimal footprint
bootstrap Absolute minimum for bootstrapping

Static Builds

Statically links libpython into the executable.

Config Modules Excluded
static_max _ctypes only
static_mid _ssl, _hashlib
static_min Most optional modules
static_bootstrap Based on Setup.bootstrap

Shared Builds

Uses a shared libpython library.

Config Modules Excluded
shared_max None
shared_mid _ctypes, _ssl, _hashlib, _decimal
shared_min Most optional modules

Framework Builds (macOS only)

Creates a macOS framework bundle. Not yet implemented.

Build Output

build/
  downloads/     # Cached source archives
  src/           # Extracted source trees
  install/
    python/      # Final Python installation

Output naming convention: py-<type>-<size>-<version>-<platform>-<arch>

Example: py-static-mid-3.13.0-darwin-arm64

Known Issues

  • If libb2 is installed on your system, the _blake2 module will link against it, creating a runtime dependency

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildpy_bundler-0.1.0.tar.gz (69.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildpy_bundler-0.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file buildpy_bundler-0.1.0.tar.gz.

File metadata

  • Download URL: buildpy_bundler-0.1.0.tar.gz
  • Upload date:
  • Size: 69.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for buildpy_bundler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f825da8ea3ed284be2c1d2ff6762f8797e5e9c0e6ad8447ea19fdefc3b92d277
MD5 03680f555b8ca11361fba986c72d629d
BLAKE2b-256 c3ca0145df954c9217023227842b11db08e530304db7e6081bcd8b040f6696d1

See more details on using hashes here.

File details

Details for the file buildpy_bundler-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for buildpy_bundler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd79404a35a97849df78873aa3ca13ba316539d8c169c1a80aee2b75eb9ff7be
MD5 48a542f21206145070d8fe27f636f18f
BLAKE2b-256 f81358ab4b05305107a6e15a4778ac701b5a87e5dfceb2aef33d84387649762b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page