r2x-cli
A comprehensive framework plugin manager for the r2x power systems modeling ecosystem. Simplifies discovery, installation, and management of r2x framework plugins.
Features
- Easy plugin management
- Built-in package resolution
- Python integration support
Building from Source
Prerequisites
Before building r2x-cli, you need:
-
Rust toolchain - Install via rustup:
|Follow the prompts and choose the default installation method.
-
UV package manager - Install via:
| -
Python 3.11, 3.12, or 3.13 - Install via uv:
After installation, restart your shell to ensure the tools are in your PATH.
Build Steps
Step 1: Clone and Build
Clone the repository:
# For users (HTTPS)
&&
# For developers (SSH)
&&
Set the PYO3_PYTHON environment variable to point to your Python installation. This is required for the PyO3 bindings to find the correct Python interpreter:
# Find your Python installation path
# Linux example:
# macOS example:
# Windows example (PowerShell):
Build in release mode:
The binary will be available at target/release/r2x (or target/release/r2x.exe on Windows).
Step 2: Install the Binary
Create the r2x binary directory and copy the built binary:
# Linux/macOS
# Windows (PowerShell)
Step 3: Link Python Dynamic Library
The r2x-cli binary needs to find the Python shared library at runtime. Create a symbolic link in the binary directory:
Linux:
# Link libpython3.12.so.1.0
# If the file doesn't exist, check the exact path with:
macOS:
# Link libpython3.12.dylib
# For Intel Macs, the path may be different:
Windows:
# Copy python312.dll (Windows uses DLL instead of symlinks)
Copy-Item "$env:USERPROFILE\.local\share\uv\python\cpython-3.12.11-windows-x86_64-none\python312.dll" `
"$env:USERPROFILE\.r2x\bin\python312.dll"
Step 4: Update PATH
Add the r2x binary directory to your PATH:
Linux/macOS (bash):
Linux/macOS (zsh):
Windows (PowerShell):
# Add to user PATH permanently
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", "User") + ";$env:USERPROFILE\.r2x\bin",
"User"
)
# For current session only:
$env:PATH = "$env:USERPROFILE\.r2x\bin;$env:PATH"
Step 5: Verify Installation
Test that r2x is working:
You should see the version information and list of available commands.
Troubleshooting Build Issues
Problem: "libpython not found" error
- Verify the symbolic link or DLL copy was created correctly
- Check that the Python library exists at the source path using
find(Linux/macOS) orGet-ChildItem(Windows) - Ensure the Python version in the library filename matches your PYO3_PYTHON version
Problem: Build fails with "PYO3_PYTHON not set"
- Make sure you exported PYO3_PYTHON before running
cargo build - Verify the path points to a valid Python executable:
$PYO3_PYTHON --version
Problem: r2x command not found
- Verify ~/.r2x/bin is in your PATH:
echo $PATH - Try using the full path:
~/.r2x/bin/r2x --version - Make sure you reloaded your shell configuration
HPC/Older Systems: On HPC systems or machines with older glibc versions, building from source is often required because pre-built binaries may be incompatible. Follow the steps above, paying special attention to setting the correct PYO3_PYTHON path for your system's Python installation.
Python Package Management
This project uses uv for handling Python packages. With uv, you don't need to worry about Python or plugin versioning—uv automatically handles dependency resolution and environment isolation for you.
Getting Started
# Initialize a new pipeline file in the current directory
# Initialize with custom filename
The r2x init command creates a template pipeline file with:
- Example variables for substitution
- Multiple pipeline examples
- Plugin configuration templates
- Comments explaining all features
You can then edit the file to configure your own pipelines.
Configuration Management
# Show current configuration
# Set configuration values
# View or set config file path
# Reset configuration to defaults
Python & Virtual Environment Management
# Install or update Python version
# Get the Python executable path (useful for scripting)
# Show current Python configuration
# Manage virtual environment
# Get or set custom venv path
# Automated venv recreation
R2X_VENV_YES=1
Install packages in your managed venv:
Cache Management
# Clean the cache directory
# View or set cache path
Pipeline Management
# List available pipelines in a file
# Execute a pipeline (explicit path and name)
# Execute from default pipeline.yaml
# Show pipeline structure
# Show pipeline flow without executing (--dry-run)
# Save pipeline output to file
The --dry-run flag displays which plugins produce/consume stdout, helping you understand data flow between pipeline stages before execution.
Plugin Management
# List all installed plugins
# Filter by plugin package name
# Filter by module/function name
# Install a plugin from PyPI
# Install from git repository
# Install from git with custom host
# Install from specific branch, tag, or commit
# Install in editable mode (for development)
# Install with cache disabled (force rebuild)
# Remove a plugin
# Sync plugin manifest (refresh plugin discovery)
# Clean plugin manifest (remove all plugins)
Running Plugins Directly
# Run a plugin with arguments (key=value format)
# Show plugin help and parameters
# Example: Run ReEDS parser
# Pass additional arguments after plugin args
System Integration
# Load and inspect a JSON system file
# Load from stdin and open IPython with system available
|
# Pipe plugin output to read command
|
Verbosity Control
# Quiet mode (suppress info logs)
# Very quiet mode (suppress info and plugin stdout)
# Verbose mode (show debug logs)
# Very verbose mode (show trace logs)
# Enable Python logging
License
BSD-3-Clause License. See LICENSE.txt for details.