class starlark_pyoxidizer.PythonDistribution

The PythonDistribution type defines a Python distribution. A Python distribution is an entity that defines an implementation of Python. This entity can be used to create a binary embedding or running Python and can be used to execute Python code.

Instances of PythonDistribution can be constructed via a constructor function or via default_python_distribution().

__init__(sha256: str, local_path: Optional[string] = None, url: Optional[string], flavor: Optional[string] = None) → PythonDistribution

Construct an instance from arguments.

The following arguments are accepted:

The SHA-256 of the distribution archive file.
Local filesystem path to the distribution archive.
URL from which a distribution archive can be obtained using an HTTP GET request.
The distribution flavor. Must be standalone.

A Python distribution is a zstandard-compressed tar archive containing a specially produced build of Python. These distributions are typically produced by the python-build-standalone project. Pre-built distributions are available at

A distribution is defined by a location and a hash.

One of local_path or url MUST be defined.


linux = PythonDistribution(

macos = PythonDistribution(
python_resources() → list[Union[PythonModuleSource, PythonExtensionModule, PythonPackageResource]]

Returns objects representing Python resources in this distribution. Returned values can be PythonModuleSource, PythonExtensionModule, PythonPackageResource, etc.

There may be multiple PythonExtensionModule with the same name.

make_python_interpreter_config() → PythonInterpreterConfig

Obtain a PythonInterpreterConfig derived from the distribution.

The interpreter configuration automatically uses settings appropriate for the distribution.

make_python_packaging_policy() → PythonPackagingPolicy

Obtain a PythonPackagingPolicy derived from the distribution.

The policy automatically uses settings globally appropriate for the distribution.

to_python_executable(name: str, packaging_policy: PythonPackagingPolicy, config: PythonInterpreterConfig) → PythonExecutable

This method constructs a PythonExecutable instance. It essentially says build an executable embedding Python from this distribution.

The accepted arguments are:

The name of the application being built. This will be used to construct the default filename of the executable.

The packaging policy to apply to the executable builder.

This influences how Python resources from the distribution are added. It also influences future resource adds to the executable.


The default configuration of the embedded Python interpreter.

Default is what make_python_interpreter_config() returns.


Libraries that extension modules link against have various software licenses, including GPL version 3. Adding these extension modules will also include the library. This typically exposes your program to additional licensing requirements, including making your application subject to that license and therefore open source. See Licensing Considerations for more.


starlark_pyoxidizer.default_python_distribution(flavor: str = "standalone", build_target: str = BUILD_TARGET, python_version: str = "3.9") → PythonDistribution

Resolves the default PythonDistribution.

The following named arguments are accepted:

Denotes the distribution flavor. See the section below on allowed values.

Denotes the machine target triple that we’re building for.

Defaults to the value of the BUILD_TARGET global constant.


X.Y major.minor string denoting the Python release version to use.

Supported values are 3.8 and 3.9.

flavor is a string denoting the distribution flavor. Values can be one of the following:


A distribution produced by the python-build-standalone project. The distribution may be statically or dynamically linked, depending on the build_target and availability. This option effectively chooses the best available standalone_dynamic or standalone_static option.

This option is effectively standalone_dynamic for all targets except musl libc, where it is effectively standalone_static.


This is like standalone but guarantees the distribution is dynamically linked against various system libraries, notably libc. Despite the dependence on system libraries, binaries built with these distributions can generally be run in most environments.

This flavor is available for all supported targets except musl libc.


This is like standalone but guarantees the distribution is statically linked and has minimal - possibly none - dependencies on system libraries.

On Windows, the Python distribution does not export Python’s symbols, meaning that it is impossible to load dynamically linked Python extensions with it.

On musl libc, statically linked distributions do not support loading extension modules existing as shared libraries.

This flavor is only available for Windows and musl libc targets.


The static versus dynamic terminology refers to the linking of the overall distribution, not libpython or the final produced binaries.

The pyoxidizer binary has a set of known distributions built-in which are automatically available and used by this function. Typically you don’t need to build your own distribution or change the distribution manually.