puccinialin

0.1.9 · active · verified Thu Apr 09

Puccinialin is a Python library designed to install Rust (cargo and rustc) into a temporary, cache-aware directory. This helps Python projects with Rust-based build backends bootstrap their Rust dependencies without modifying the host's environment. The current version is 0.1.9, and its release cadence appears irregular, with updates driven by need rather than a fixed schedule.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `setup_rust` to install Rust and obtain the necessary environment variables. These variables can then be used to execute Rust commands, such as `cargo build`, within a Python script.

import os
from subprocess import check_call
from puccinialin import setup_rust

# Install Rust into a user cache directory by default, or specify a path
extra_env = setup_rust()

# Use the returned environment variables to call Rust tools like cargo
# For example, to run 'cargo build' with the installed Rust environment:
try:
    print("Attempting to run 'cargo build' with installed Rust...")
    # Combine current environment with the extra_env provided by puccinialin
    check_call(["cargo", "build"], env={**os.environ, **extra_env})
    print("Cargo build command executed successfully.")
except Exception as e:
    print(f"Error executing cargo build: {e}")
    print("Note: 'cargo build' requires a Rust project in the current directory. This is an example of how to use the setup_rust output.")

view raw JSON →