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().


Resolves the default PythonDistribution.

The following named arguments are accepted:


(string) Denotes the distribution flavor. See the section below on allowed values.

Defaults to standalone.


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

Defaults to the value of the BUILD_TARGET global constant.


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

Supported values are 3.8 and 3.9.

Defaults to 3.8.

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.


Construct a PythonDistribution from arguments.

The following arguments are accepted:

(string) The SHA-256 of the distribution archive file.
(string) Local filesystem path to the distribution archive.
(string) URL from which a distribution archive can be obtained using an HTTP GET request.
(string) 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(



Returns a list of PythonModuleSource representing Python source modules present in this distribution.


Returns a list of PythonPackageResource representing resource files present in this distribution.

The include_test boolean argument controls whether resources associated with test packages are included.


Returns a list of PythonExtensionModule representing extension modules in this distribution.

There may exist multiple extensions with the same name.


Obtain a PythonInterpreterConfig derived from the distribution.

The interpreter configuration automatically uses settings appropriate for the distribution.


Obtain a PythonPackagingPolicy derived from the distribution.

The policy automatically uses settings globally appropriate for the distribution.


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

The accepted arguments are:

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

(PythonPackagingPolicy) 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.


(PythonInterpreterConfig) The default configuration of the embedded Python interpreter.

Default is what PythonDistribution.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.