API¶
Pyrig plugin that builds and publishes standalone project executables.
Installing this package as a dependency extends a pyrig-built project with everything needed to package its entry point as a distributable binary, publish one for every supported operating system alongside each release, and run that entry point locally the same way the packaged binary does.
main ¶
rig ¶
Mirrored namespace through which this plugin extends pyrig's scaffolding.
Mirrors the pyrig.rig package layout so pyrig's cross-package plugin
discovery finds this plugin's contributions automatically.
cli ¶
CLI commands this plugin contributes to a project.
commands ¶
Backend implementations for this plugin's CLI commands.
Each module implements exactly one command as a plain callable, decoupled from the CLI registration layer. This separation lets the registration layer import commands lazily, loading each module only when its command is invoked.
run ¶
CLI command implementation for running the project's entry-point module.
run_main ¶
Execute the project's main.py as the __main__ module.
Runs the file by path rather than importing it, so its
if __name__ == "__main__" guard fires and calls main, mirroring how the
built executable runs the same file.
Source code in src/pyrig_executables/rig/cli/commands/run.py
subcommands ¶
Project-specific CLI commands.
Functions defined directly in this module are discovered and registered as
top-level CLI commands. Module-level typer.Typer instances are registered
as command groups, with each group named after the kebab-case form of its
variable name.
run ¶
Run the project.
This command runs the project's main.py file as the __main__ module.
configs ¶
Declarative definitions of the configuration files this plugin contributes.
This package is this plugin's discovery scope for pyrig's config-file
management: every file this plugin manages is defined here and validated
during pyrig sync.
icon ¶
Config that scaffolds the executable's icon as rig/resources/icon.png.
IconConfigFile ¶
Bases: DictConfigFile
Config file that scaffolds the icon.png used as the executable's icon.
The release workflow bundles this file into the built executable as its icon. The scaffolded file is a default -- replace it with your own; it is created only when missing, so a project's own icon is preserved.
Note
If the file exists but is not a valid PNG, validation raises
RuntimeError rather than automatically restoring the default icon.
is_correct ¶
is_correct() -> bool
Return whether the icon file starts with the PNG signature.
Only the 8-byte PNG magic number is checked; the rest of the file's bytes are not otherwise validated.
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
otherwise. |
Source code in src/pyrig_executables/rig/configs/icon.py
main ¶
Configuration for the project's main entry-point module.
Scaffolds a main.py containing a callable main function in every project
that installs this plugin. The module provides the entry point that the
executable builder bundles into a standalone binary, so this config guarantees
that a suitable build target always exists.
MainConfigFile ¶
Bases: CopyModuleConfigFile
Scaffolding for the project's main.py entry-point module.
Copies this plugin's own entry-point module into the target project as
main.py. Once the file exists, a project's own implementation stands
rather than being overwritten, as long as it still satisfies the
entry-point contract that is_correct checks for.
copy_module ¶
copy_module() -> ModuleType
has_callable_main ¶
has_callable_main() -> bool
Return whether the target module exposes a callable main attribute.
has_main_guard ¶
has_main_guard() -> bool
Return whether the target module's file contains the __main__ guard.
Matched via plain substring search, so the guard text must appear
exactly as returned by main_guard.
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in src/pyrig_executables/rig/configs/main.py
is_correct ¶
is_correct() -> bool
Return whether the project's main.py is valid.
Overrides the inherited content check: main.py is correct once the
target module exposes a callable main and contains a __main__
execution guard, regardless of what the function body does. This lets
a project's own entry-point implementation stand unmodified.
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
|
Source code in src/pyrig_executables/rig/configs/main.py
version_control ¶
Version control configuration adjusted for standalone executable distribution.
Extends the base version control setup, local or remote, to account for building and publishing standalone executables alongside a release.
remote ¶
Overrides for the project's GitHub-hosted remote repository configuration.
workflows ¶
Overrides for the project's GitHub Actions workflow configuration.
Extension of the release workflow that builds and attaches executables.
Bases: ReleaseWorkflowConfigFile
Release workflow that builds and attaches standalone executables.
Extends the base release workflow with a matrix job that builds a single-file executable for every supported operating system and attaches each one to the GitHub release as a release asset, alongside the generated changelog.
Build the workflow-artifact name for the given runner OS.
Single source of the executable-<os> artifact label. Kept
deliberately generic and distinct from executable_name, so it does
not collide with artifacts that other actions may name after the
project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
os
|
str
|
The runner OS suffix, or |
required |
Returns:
| Type | Description |
|---|---|
str
|
The |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
collect_all_modules() -> Iterable[ModuleType]
Return the modules to bundle in full (data, submodules, binaries).
Empty by default, since the project's own resources package is pure
data and is covered by collect_data_modules instead. Override to
bundle additional modules that ship submodules or binaries alongside
their data.
Returns:
| Type | Description |
|---|---|
Iterable[ModuleType]
|
No modules, by default. |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
collect_data_modules() -> Iterable[ModuleType]
Return the resource modules whose data files to bundle into the executable.
Resolves the project's rig/resources package, the location the
pyrig-resources plugin scaffolds and validates. Locating the
project's resources is a config concern, so it lives here rather than
in the project-agnostic executable builder tool. Override to bundle
additional pure-data resource packages.
Returns:
| Type | Description |
|---|---|
Iterable[ModuleType]
|
The project's resource modules (the |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
executable_name() -> str
Build the per-OS name of the executable binary and release asset.
Combines the project name with the runner OS so each platform's binary
gets a unique, recognizable, collision-free name (e.g.
pyrig-executables-Linux). The OS is resolved at workflow runtime.
Returns:
| Type | Description |
|---|---|
str
|
The |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
insert_os() -> str
Build the matrix job that compiles the executable on every OS.
Runs across the default OS matrix (Linux, Windows, macOS), since
pyinstaller cannot cross-compile and each binary must be built on
its target platform.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Job configuration with an OS matrix strategy, a dynamic |
dict[str, Any]
|
value, and the build and upload steps. |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build the release job, gated on the executable build job.
Adds a needs dependency on executable so the release is
only published once every platform's binary is available to attach.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The base release job with a |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build the complete set of workflow jobs.
Adds the executable build job to the base release jobs.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict containing the executable build job together with the base |
dict[str, Any]
|
release jobs. |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
priority() -> float
Return a priority one step after the resources config's.
Building the executable requires the project's resources package to already exist, so this config must validate after it. Deriving from its priority instead of hard-coding a value keeps this config's priority in step with any future change to the resources config's own priority.
Returns:
| Type | Description |
|---|---|
float
|
The resources config's priority lowered by one |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build a step that compiles the project into a single-file executable.
Runs pyinstaller --onefile against the project's entry-point
module, naming the output binary via executable_name.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Step that runs the executable builder via uv. |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build the create-release step, attaching the built executables.
Extends the base release step by attaching every binary downloaded into
dist/ as a release asset.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The base create-release step with |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build a step that downloads every executable artifact into dist/.
Merges every per-OS executable artifact, matched by the
artifact_name glob, into a single dist/ directory so they can be
attached to the release with one glob.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Step using |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build a step that uploads the built executable as a workflow artifact.
Uploads the contents of dist/ under the per-OS artifact_name so
the publish job can later download every platform's binary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Step using |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build the ordered steps for the executable build job.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
Steps that set up the environment, build the single-file |
list[dict[str, Any]]
|
executable, and upload it as a per-OS artifact. |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
Build the ordered steps for the release job.
Inserts a step that downloads every platform's executable immediately before the create-release step, since the release must not be created before every binary is available to attach.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
The base publish steps with the executable download step inserted |
list[dict[str, Any]]
|
just before the create-release step. |
Source code in src/pyrig_executables/rig/configs/version_control/remote/workflows/release.py
resources ¶
Bundled static resource files read when scaffolding executable projects.
Holds verbatim resource files that config file subclasses copy into a project that builds a standalone executable.
tools ¶
Wrappers for the external CLI tools this plugin contributes to a project.
executables ¶
Tool wrappers for building standalone executables.
builder ¶
Tool wrapper for bundling the project into standalone release executables.
ExecutableBuilder ¶
Bases: Tool
Wrapper for pyinstaller, the tool that builds standalone executables.
Exposes a project-info badge showing the cumulative download count across all GitHub release assets, linking to the releases page where the built executables are published.
build_args(
*args: str,
name: str,
entry_point: Path,
icon: Path,
collect_all_modules: Iterable[ModuleType] = (),
collect_data_modules: Iterable[ModuleType] = (),
) -> Args
Build the pyinstaller command that bundles a single-file executable.
Bundles each module with its own --collect-all or --collect-data
flag rather than pointing --add-data at a path. This preserves the
package layout so resources stay locatable at runtime through
importlib.resources in both development and the frozen
executable, and sidesteps the platform-specific separator
--add-data requires. --collect-all also pulls in a module's
submodules and any binaries it ships, so it suits modules that are
not known to be pure data (e.g. an extension point where callers may
pass anything); --collect-data is narrower and suits known
pure-data packages, avoiding unrelated submodules/binaries. The
build runs in console mode by default; pass --windowed through
*args for a GUI application that should run without a console
window (this instead produces a .app bundle directory on macOS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Additional arguments forwarded to |
()
|
name
|
str
|
Output name for the executable (without an OS-specific
extension; |
required |
entry_point
|
Path
|
Path to the entry-point script to bundle. |
required |
icon
|
Path
|
Path to the icon image. A non-native format (e.g. PNG) is
converted to the per-OS format ( |
required |
collect_all_modules
|
Iterable[ModuleType]
|
Modules to bundle in full (data,
submodules, and binaries), one |
()
|
collect_data_modules
|
Iterable[ModuleType]
|
Modules whose data files only are
bundled, one |
()
|
Returns:
| Type | Description |
|---|---|
Args
|
Args for the |
Source code in src/pyrig_executables/rig/tools/executables/builder.py
Return the dev dependencies required to build executables.
Extends the default with pillow so pyinstaller can convert a
non-native icon image (e.g. PNG) into the per-OS icon format (.ico
/ .icns) at build time.
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
|
Source code in src/pyrig_executables/rig/tools/executables/builder.py
dist_dir() -> Path
Return the directory pyinstaller writes built executables to.
Single source of truth for the output location, so it never drifts out of sync with other places that need it.
Returns:
| Type | Description |
|---|---|
Path
|
The |
Source code in src/pyrig_executables/rig/tools/executables/builder.py
image_url() -> str
Return the shields.io URL for the GitHub release downloads badge.
Source code in src/pyrig_executables/rig/tools/executables/builder.py
Return the build artifact paths to exclude from version control.
Returns:
| Type | Description |
|---|---|
str
|
The |
...
|
the generated |
Source code in src/pyrig_executables/rig/tools/executables/builder.py
pyrigger ¶
Customization of the pyrig CLI tool for projects that build executables.
Pyrigger ¶
Bases: Pyrigger
Pyrig CLI tool wrapper that extends project initialization for this plugin.
setup_steps ¶
Insert an extra pyrig sync step into the base initialization sequence.
A duplicate of the base pyrig sync step is inserted before the original one.
We need them to run twice so that the test stubs for the generated main.py file.