Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Nautechsystems Nautilus trader V2 Pyproject Configuration

From Leeroopedia


Knowledge Sources
Domains Build_Tooling, Python, Rust
Last Updated 2026-02-10 08:00 GMT

Overview

Python project configuration for the NautilusTrader v2 package using maturin as the build backend for PyO3 Rust-to-Python compilation.

Description

The python/pyproject.toml defines the nautilus-trader v2.0.0 package, which uses maturin (instead of poetry-core + custom build.py) as the build backend for compiling Rust PyO3 bindings directly into a Python extension module. The maturin configuration points to crates/pyo3/Cargo.toml as the manifest, compiles to nautilus_trader._libnautilus module name, and enables feature flags: extension-module, high-precision, redis, postgres, defi, hypersync, and tracing-bridge. A pre-build hook (python generate_stubs.py) automatically generates type stubs before each build.

Runtime dependencies are minimal: numpy, pandas, pyarrow, python-dotenv, and pytz. Development groups include maturin, mypy, pre-commit, ruff (dev) and pytest with plugins (test). The file includes comprehensive ruff linting rules, isort configuration, and mypy strict type checking settings. Python versions 3.12-3.14 are supported with LGPL-3.0 license.

Usage

This configuration is used for v2 builds via maturin develop (development) or maturin build (distribution). The v2 pipeline replaces the v1 poetry-core + build.py approach with maturin's native Rust compilation, eliminating the need for a custom build script for the Rust portion.

Code Reference

Source Location

Signature

[project]
name = "nautilus-trader"
version = "2.0.0"
requires-python = ">=3.12,<3.15"
dependencies = [
  "numpy>=1.26.4",
  "pandas>=2.3.3,<3.0.0",
  "pyarrow>=22.0.0",
  "python-dotenv>=1.2.1",
  "pytz>=2025.2.0",
]

[build-system]
requires = ["maturin>=1.11.5", "patchelf"]
build-backend = "maturin"

[tool.maturin]
manifest-path = "../crates/pyo3/Cargo.toml"
module-name = "nautilus_trader._libnautilus"
python-source = "."
features = [
  "extension-module",
  "high-precision",
  "redis",
  "postgres",
  "defi",
  "hypersync",
  "tracing-bridge",
]

[tool.maturin.scripts]
pre-build = "python generate_stubs.py"

Import

# Development build (v2)
cd python/
maturin develop

# Release build
cd python/
maturin build --release

# Install from source
pip install python/

I/O Contract

Inputs

Name Type Required Description
tool.maturin.manifest-path String Yes Path to Cargo.toml for the PyO3 crate
tool.maturin.features List[String] Yes Rust feature flags to enable during compilation
tool.maturin.scripts.pre-build String No Script to run before compilation (stub generation)
project.dependencies List[String] Yes Runtime Python dependencies

Outputs

Name Type Description
_libnautilus.so Extension Compiled PyO3 extension module
.pyi stubs Files Type stubs generated by pre-build hook
wheel Package Distributable Python wheel with extension

Usage Examples

# Development workflow (v2)
cd python/

# Build and install in development mode
maturin develop

# Build with specific features
maturin develop --features "high-precision,redis"

# Build release wheel
maturin build --release

# Run tests after build
pytest

# Type check with generated stubs
mypy nautilus_trader/

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment