Skip to content

muxtools.utils.binaries.runner

use_binary_package

use_binary_package(package: str) -> Generator[None, None, None]

Select an installed provider for its executables within this block.

Honors configured version constraints and leaves unrelated executable lookups unchanged. Nested selections are restored on exit. Without configuration, packages are read from global storage; system mode does not support selection.

Source code in muxtools/utils/binaries/runner.py
@contextmanager
def use_binary_package(package: str) -> Generator[None, None, None]:
    """Select an installed provider for its executables within this block.

    Honors configured version constraints and leaves unrelated executable lookups
    unchanged. Nested selections are restored on exit. Without configuration,
    packages are read from global storage; system mode does not support selection.
    """
    _validate_package(package)
    config = resolve_binary_config(discover_config())
    root = scope_path(config)
    items = _installed_metadata(root)
    if not any(item["name"] == package for item in items):
        raise FileNotFoundError(f"Package {package!r} is not installed; run 'muxtools binaries install {package}'")
    names = _provided(package, items, _cached_catalog())
    token = _package_selections.set(_package_selections.get() | dict.fromkeys(names, package))
    try:
        yield
    finally:
        _package_selections.reset(token)

get_managed_executable

get_managed_executable(name: str, config: ProjectConfig | None = None, *, package: str | None = None) -> str | None

Resolve an executable, optionally selecting a canonical installed package.

Selection honors configured constraints and never falls back to another provider. Custom vof_exe_* paths take precedence over package selection. Strict binary configuration disables PATH fallback for undeclared executables.

Source code in muxtools/utils/binaries/runner.py
def get_managed_executable(name: str, config: ProjectConfig | None = None, *, package: str | None = None) -> str | None:
    """Resolve an executable, optionally selecting a canonical installed package.

    Selection honors configured constraints and never falls back to another
    provider. Custom ``vof_exe_*`` paths take precedence over package selection.
    Strict binary configuration disables PATH fallback for undeclared executables.
    """
    return _resolve_executable(name, config, package=package)