Skip to content

Rust phase 1: scaffold iaf-core crate (PyO3 + maturin + CI wheels) #522

@MDUYN

Description

@MDUYN

Goal

Stand up a minimal Rust crate iaf-core inside the repo (or a sibling repo, decision in this spike) that can be imported from Python via PyO3 + maturin, with a green CI build that produces wheels for all supported targets. No business logic yet — just the scaffolding and a hello_from_rust() smoke function callable from Python.

Tasks

  • Decide repo layout: iaf_core/ subcrate inside this repo (Cargo + maturin) vs. separate iaf-core repo published as investing-algorithm-framework-core on PyPI. Document trade-offs.
  • Cargo workspace with iaf-core (lib) and iaf-core-py (PyO3 cdylib).
  • pyproject.toml build backend = maturin. Optional install of the native module via an extra (e.g. pip install investing-algorithm-framework[native]) so users without a Rust toolchain are unaffected.
  • Internal Python dispatch: from investing_algorithm_framework._native import recalculate_metrics falls back to the pure-Python implementation when the native module is absent. Add a feature-flag env var (e.g. IAF_NATIVE=0) to force pure-Python for debugging.
  • CI matrix: build wheels via maturin-action for macOS (x86_64 + arm64), Linux (x86_64 + arm64 manylinux), Windows; Python 3.10 / 3.11 / 3.12. Linux arm64 via cross or maturin build --target aarch64-unknown-linux-gnu.
  • sdist that builds without a Rust toolchain by falling back to pure-Python (the native module is optional).
  • cargo fmt, cargo clippy -- -D warnings, cargo test in CI.
  • A hello_from_rust() smoke test exercised from a Python unit test, gated on the native module being importable.

Acceptance criteria

  • pip install -e .[native] works locally on macOS arm64 with a stable Rust toolchain.
  • pytest tests/native/test_smoke.py passes both with and without the native module installed (skipped when absent).
  • Wheels are produced on every push to dev and uploaded as CI artifacts.

Out of scope

  • Any actual metric or bundle logic (covered by follow-up issues).
  • Publishing to PyPI (separate release issue once parity is reached).

Part of the Epic: hybrid Python + Rust acceleration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance / memory optimizationrelease:backlogNot yet targetedrustRust port / native accelerationtype:spikeResearch/investigation — produces a plan, not code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions