def with_env_recursive(cmd, **envvars):
    """
    Recursively updates the environment of cmd and all its subcommands.

    Args:
        cmd - A plumbum command-like object
        **envvars - The environment variables to update

    Returns:
        The updated command.
    """
    from plumbum.commands.base import BoundCommand, BoundEnvCommand
    if isinstance(cmd, BoundCommand):
        cmd.cmd = with_env_recursive(cmd.cmd, **envvars)
    elif isinstance(cmd, BoundEnvCommand):
        cmd.envvars.update(envvars)
        cmd.cmd = with_env_recursive(cmd.cmd, **envvars)
    return cmd
def with_env_recursive ( cmd , ** envvars ) : from plumbum . commands . base import BoundCommand , BoundEnvCommand if isinstance ( cmd , BoundCommand ) : cmd . cmd = with_env_recursive ( cmd . cmd , ** envvars ) elif isinstance ( cmd , BoundEnvCommand ) : cmd . envvars . update ( envvars ) cmd . cmd = with_env_recursive ( cmd . cmd , ** envvars ) return cmd
Recursively updates the environment of cmd and all its subcommands.

    Args:
        cmd - A plumbum command-like object
        **envvars - The environment variables to update

    Returns:
        The updated command.