Repolode
pex-tool

pex-tool/pex

A Python tool that packages applications and their dependencies into single executable .pex files, similar to a portable virtualenv.

Stars
4,230
Forks
321
Open issues
58
Last commit
3 hours ago

What is it?

Pex generates .pex (Python EXecutable) files, which are self-contained Python environments that can be run like a normal executable. The idea extends PEP 441 and aims to make deploying a Python application as simple as copying a file. A single pex file can include multiple platform-specific distributions, so one archive can run across different operating systems.

The pex command builds these files from requirements passed on the command line, from a pip freeze output, or from a project's console_scripts entry points. It can also launch ephemeral environments, for example running a script with Flask available without creating a persistent virtualenv. Specific interpreter types such as PyPy can be selected at build time.

Installation is available via pip, and the project documents further usage and build integration with tools such as Pants and Buck at its documentation site.

Key features

  • 01Builds single-file executable Python environments from dependencies or requirements files.
  • 02Can bundle platform-specific distributions so one pex runs on multiple operating systems.
  • 03Exposes console_scripts entry points as standalone executables.
  • 04Supports launching ephemeral environments for quick experiments.
  • 05Allows selecting a specific interpreter, such as PyPy, at build time.

Use cases

  • Shipping a Python command-line tool or service as one file to servers without a separate install step.
  • Freezing a working virtualenv into a portable archive with pip freeze input.
  • Running a quick script with a few libraries without creating a project environment.
  • Integrating reproducible Python builds into build systems such as Pants or Buck.

Quick start

  1. 1

    Install pex from PyPI

    pip install pex
  2. 2

    Build a pex file bundling requests, flask and psutil

    pex requests flask 'psutil>2,<3' -o my_app.pex

Topics

FAQ

What is pex?
A Python tool that packages applications and their dependencies into single executable .pex files, similar to a portable virtualenv. Pex generates .pex (Python EXecutable) files, which are self-contained Python environments that can be run like a normal executable. The idea extends PEP 441 and aims to make deploying a Python application as simple as copying a file. A single pex file can include multiple platform-specific distributions, so one archive can run across different operating systems.
Is pex free to use? What license does it have?
pex is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is pex still maintained?
Actively maintained. The last commit to pex was on Oct 24, 2026.
What can I use pex for?
Shipping a Python command-line tool or service as one file to servers without a separate install step. Freezing a working virtualenv into a portable archive with pip freeze input. Running a quick script with a few libraries without creating a project environment. Integrating reproducible Python builds into build systems such as Pants or Buck.
How do I install pex?
Install pex from PyPI: pip install pex Build a pex file bundling requests, flask and psutil: pex requests flask 'psutil>2,<3' -o my_app.pex
Where can I get pex?
The source code and installation instructions are on GitHub: https://github.com/pex-tool/pex

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects