from pyinfra.operations import cargocargo.packages( name="Install CLI tools written in Rust", packages=[ "ripgrep", # Fast grep alternative "fd-find", # Fast find alternative "bat", # Cat with syntax highlighting "exa", # Modern ls replacement "tokei", # Code statistics ],)
Cargo installs binaries to ~/.cargo/bin by default:
from pyinfra.operations import server# Ensure ~/.cargo/bin is in PATHserver.shell( name="Add cargo bin to PATH", commands=[ 'echo "export PATH=$HOME/.cargo/bin:$PATH" >> ~/.bashrc', ],)
Update Cargo Itself
Update cargo and rustc:
from pyinfra.operations import serverserver.shell( name="Update Rust toolchain", commands=["rustup update"],)
List Installed Packages
View installed cargo packages:
from pyinfra.operations import serverserver.shell( name="List cargo packages", commands=["cargo install --list"],)
Clean Build Cache
Clean cargo’s build cache:
from pyinfra.operations import serverserver.shell( name="Clean cargo cache", commands=["cargo cache --autoclean"],)
Install with Locked Dependencies
Install with exact dependency versions:
from pyinfra.operations import serverserver.shell( name="Install with locked dependencies", commands=["cargo install ripgrep --locked"],)
Cross-Compilation
Install for different targets:
from pyinfra.operations import server# Add targetserver.shell( name="Add ARM target", commands=["rustup target add aarch64-unknown-linux-gnu"],)# Install for targetserver.shell( name="Install for ARM", commands=[ "cargo install ripgrep --target aarch64-unknown-linux-gnu", ],)