Installation¶
RustyStats requires Python 3.9+ and a Rust toolchain for building from source.
Prerequisites¶
Python¶
Ensure you have Python 3.9 or later:
Rust¶
Install Rust via rustup if not already installed:
Verify installation:
uv (Recommended)¶
We use uv for Python package management:
Development Installation¶
Clone and build from source:
# Clone the repository
git clone https://github.com/PricingFrontier/rustystats.git
cd rustystats
# Install in development mode
uv run maturin develop
# Or with pip
pip install maturin
maturin develop
Development Mode
maturin develop compiles the Rust code and installs it in your current Python environment. Changes to Rust code require re-running this command.
Verify Installation¶
import rustystats as rs
import numpy as np
# Quick test
y = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
X = np.column_stack([np.ones(5), np.array([1, 2, 3, 4, 5])])
result = rs.fit_glm(y, X, family="gaussian")
print(f"Coefficients: {result.params}")
print(f"RustyStats is working!")
Dependencies¶
Core (Required)¶
numpy>=1.20- Array operations
Optional¶
polars>=1.0- DataFrame support for formula APIpyarrow- Parquet file support
Development¶
pytest>=7.0- Testingmaturin>=1.4- Build toolstatsmodels>=0.14- Comparison testing
Troubleshooting¶
Compilation Errors¶
If Rust compilation fails:
- Update Rust:
rustup update - Check Cargo.toml: Ensure all dependencies are available
- Clean build:
cargo cleanthen rebuild
Import Errors¶
If import rustystats fails:
- Ensure you ran
maturin develop(not justmaturin build) - Check you're in the correct Python environment
- Verify with
pip list | grep rustystats
Performance Issues¶
For optimal performance:
- Build in release mode:
maturin develop --release - Ensure Rayon parallelism isn't disabled by environment variables