| type | Overview | ||||
|---|---|---|---|---|---|
| title | Portable Python Overview | ||||
| description | A CLI and library that compiles statically-linked, relocatable CPython binaries from source, and validates their portability. | ||||
| tags |
|
||||
| timestamp | 2026-06-23 00:00:00 UTC |
portable-python compiles CPython from source into a binary that is statically linked and relocatable: the resulting tarball can be unpacked into any folder and used immediately, with no installer and no dependency on system shared libraries. It targets Linux and macOS (Intel and Apple Silicon). Windows is not supported.
It is both:
- A CLI with one entry point,
portable-python(see CLI). - A Python library (
from portable_python import BuildSetup) for driving builds or inspections programmatically.
dist/cpython-3.13.2-macos-arm64.tar.gz
Unpack and run, no installation step:
tar -C ~/versions/ -xf dist/cpython-3.13.2-macos-arm64.tar.gz
~/versions/3.13.2/bin/python --version- Resolve the requested
PythonSpec(family + version) and target platform via thePPGsingleton. - Select which external modules to compile, based on config and telltale detection.
- Compile external C libraries first (openssl, zlib, xz, …) into a shared
build/deps/prefix — see build layout. - Compile CPython (
Cpython), pointing itsconfigure/makeatbuild/deps/via injected environment variables (CPATH, LDFLAGS, …). - Finalize: clean test files, byte-compile, relativize paths so the install is relocatable.
- Validate portability with the
PythonInspector, then compress intodist/.
The whole pipeline is coordinated by BuildSetup.
- One job, done well. Compile a portable python, validate it really is portable, drop the result in
dist/. - No source patches. C compilation relies solely on
configure/makeflags (e.g.--enable-shared=no), never on modifying upstream source. - Validated builds. A large part of the effort is the
inspectcapability that proves an installation is portable (and explains why if it isn't). - Only recent, non-EOL Pythons. No historical support; older versions are dropped without notice as the tool evolves.
- Pure Python, testable. No shell scripts. 100% test coverage, a
--dryrunmode for fast iteration, and the ability to run under a debugger.
Dry-run a build to see exactly what would happen without doing it:
portable-python --dryrun build 3.13.2Inspect any existing python for portability:
portable-python inspect /usr/bin/python3