Pex builds .pex files, lock files, and virtualenv-style bundles that package Python apps and dependencies. A CLI and library simplify shipping Python as a single runnable artifact.
Overview
Pex implements the Python EXecutable format described in PEP 441 spirit: self-contained environments you can copy and run like a binary deployment unit. A .pex can bundle dependencies and may include multiple platform-specific Python builds so one artifact works on Linux and macOS.
The pex command-line tool resolves requirements, entry points, and interpreters when assembling files. Build systems such as Pants, Buck, and Gradle-related tooling can emit .pex outputs directly. The same project exposes APIs for generating lock files and venvs.
Typical workflows install via pip, invoke pex with package names to launch an interpreter or build a saved .pex, and tune resolution with flags documented on the project site. Documentation covers bdist_pex, runtime environment variables, containers, and long-running daemons.
Historically the format supported deploying Python applications without installing packages on each host, with operational use cited from large-scale Python deployments.
Key features
- .pex self-contained Python environments
- CLI requirement and entry-point resolution
- Multi-platform bundles in one file
- Lock file generation
- Interpreter selection including PyPy
- Pants, Buck, and Gradle integration
- bdist_pex setuptools integration
- Virtualenv-like packaging model
Use cases
- Ship Python services as one file
- Reproducible dependency lockfiles
- Cross-platform internal tool distribution
- CI-built deployable Python artifacts