Installation¶
Brahe is available for both Python and Rust. Choose the installation method that best fits your workflow.
Python Installation¶
Using pip (Recommended)¶
The simplest way to install Brahe is using pip from PyPI:
This will install the latest stable release of Brahe and all required dependencies.
Optional Dependencies¶
Brahe includes optional dependencies for enhanced plotting capabilities:
Using uv (Fast Alternative)¶
uv is a fast Python package installer. To install Brahe with uv:
# Install brahe
uv pip install brahe
# Or with optional plot dependencies
uv pip install "brahe[plots]"
Verifying Installation¶
After installation, verify that Brahe is working correctly:
import brahe as bh
print(bh.__version__)
# Test basic functionality
a = bh.R_EARTH + 500e3 # Semi-major axis for 500 km altitude
T = bh.orbital_period(a)
print(f"Orbital period: {T/60:.2f} minutes")
Building from Source (Python)¶
If you want to build Brahe from source (e.g., for development or to use unreleased features), follow these steps:
Prerequisites¶
-
Rust toolchain (required for building the native extensions):
-
Configure Rust to Use Nightly:
-
Python 3.9+ with development headers:
Building with uv (Recommended)¶
# Clone the repository
git clone https://github.com/duncaneddy/brahe.git
cd brahe
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Sync dependencies and create virtual environment
uv sync
# Build and install in editable mode
uv pip install -e .
# Activate the virtual environment
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
Building with pip and maturin¶
# Clone the repository
git clone https://github.com/duncaneddy/brahe.git
cd brahe
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
# Install maturin (the build tool for PyO3)
pip install maturin
# Build and install in development mode
maturin develop --release
# Or install normally
pip install -e .
Development Installation¶
For development work, install with development dependencies:
This includes tools for: - Testing (pytest, pytest-cov) - Documentation (mkdocs, mkdocstrings) - Code quality (ruff, pre-commit) - Type stubs generation (pyo3-stubgen)
Running Tests¶
After building from source, verify everything works:
# Run Python tests
pytest tests/ -v
# Run Rust tests
cargo test
# Run with code coverage
pytest tests/ --cov=brahe --cov-report=html
Updating Type Stubs¶
If you modify the Rust Python bindings, regenerate Python type stubs:
Rust Installation¶
To use Brahe in your Rust project, add it to your Cargo.toml:
Building the Rust Library¶
# Clone the repository
git clone https://github.com/duncaneddy/brahe.git
cd brahe
# Build the library
cargo build
# Run tests
cargo test
# Build documentation
cargo doc --open
Troubleshooting¶
Common Issues¶
"Failed to build wheel" (Python)
- Ensure Rust is installed: rustc --version
- Update Rust: rustup update
- Install Python development headers (see prerequisites above)
Import errors after installation
- Verify installation: pip show brahe
- Check Python version: python --version (must be 3.9+)
- Try reinstalling: pip install --force-reinstall brahe
Cartopy installation fails
- On Ubuntu/Debian: sudo apt-get install libgeos-dev
- On macOS: brew install geos
- See Cartopy installation docs
Type hints not working in IDE
- Ensure type stubs are installed: ls $(python -c "import brahe; print(brahe.__path__[0])")/_brahe.pyi
- If missing, regenerate: ./scripts/generate_stubs.sh (from source installation)
Getting Help¶
If you encounter issues:
- Check the GitHub Issues for similar problems
- Review the documentation
- Open a new issue with:
- Your operating system and version
- Python/Rust version
- Complete error message
- Steps to reproduce
Platform-Specific Notes¶
macOS¶
On Apple Silicon (M1/M2/M3): - Brahe builds natively for ARM64 - Ensure you have the ARM64 version of Python
Windows¶
- Install Microsoft C++ Build Tools
- Consider using WSL2 for a smoother development experience
Linux¶
Most distributions work out-of-the-box. If you encounter issues:
- Install build essentials: sudo apt-get install build-essential
- Ensure GEOS library is installed for Cartopy