---
title: "安装"
description: "分别构建 Rust crate 和 Python wheel；MPI 功能通过独立 Cargo feature 启用。"
eyebrow: "开始使用"
---

## 环境要求 {#requirements}

| 组件 | 最低要求 | 说明 |
| --- | --- | --- |
| Rust crate | Rust 1.82 | 普通寻路与 native CPU 执行 |
| Python wheel | Rust 1.83 · Python 3.9 · NumPy 1.23 | PyO3 0.28 构建扩展 |
| MPI | 系统 MPI + Cargo feature `mpi` | 启用 `mpi` feature 并构建 `tnmpi` 时需要 |

## 构建 Rust crate {#rust}

```bash
git clone https://github.com/2hengy1/arctn.git
cd arctn
cargo build --release --locked
cargo test --locked --test correctness
```

普通寻路和单机执行不需要 MPI。`--locked` 按仓库中的 `Cargo.lock` 固定依赖版本。

## 构建 Python wheel {#python}

```bash
cd arctn/pybind
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install "maturin>=1.9.3,<2.0"
python -m maturin build --release --locked --out target/wheels
python -m pip install --force-reinstall target/wheels/arctn-*.whl
python test_install.py
```

基础 wheel 已包含 ArcTN native CPU executor。`pip install 'arctn[execution]'` 安装可选依赖：opt\_einsum 用于外部数组后端执行，Cotengra 用于树接口。Quimb 工作流可用 `pip install 'arctn[quimb]'`。CuPy、PyTorch、JAX 等数组库按目标硬件另行安装。

## 启用 MPI {#mpi}

```bash
cargo build --release --locked --features mpi --bin tnmpi
mpirun -n 4 target/release/tnmpi --help
```

> **MPI 功能边界**
>
> `tnmpi` 主要用于固定路径的 `f64` 切片执行，不运行分布式 Light / Heavy pathfinding。
