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.

Principle:Nautechsystems Nautilus trader Python Package Configuration

From Leeroopedia


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

Overview

A standardized approach to declaring Python package metadata, dependencies, build system, and tool configuration in a single pyproject.toml file.

Description

Python Package Configuration consolidates all project metadata, dependency specifications, build system configuration, and development tool settings into pyproject.toml as specified by PEP 621 and PEP 517. This replaces the legacy approach of scattering configuration across setup.py, setup.cfg, requirements.txt, .flake8, mypy.ini, pytest.ini, and other files. For projects with compiled extensions (Cython, Rust/PyO3), the [build-system] section specifies build-time requirements and a custom build backend or script. Optional dependency groups (extras) allow users to install only the exchange adapters they need, keeping the base installation lightweight.

Usage

Apply this principle for any Python package that needs to be distributed. It is the standard approach for Python packaging since PEP 621 adoption. For projects with compiled extensions, the build-system section must declare all build-time dependencies (Cython, numpy for header generation, setuptools, etc.) that are not runtime dependencies.

Theoretical Basis

The configuration follows a declarative metadata + imperative build model:

# Abstract model (NOT real implementation)
metadata = parse_project_table(pyproject_toml)  # Declarative: name, version, deps
build_system = parse_build_system(pyproject_toml)  # Imperative: build backend + script
tool_config = parse_tool_tables(pyproject_toml)  # Declarative: ruff, mypy, pytest

# Build process:
install_build_requires(build_system.requires)
backend = import(build_system.build_backend)
wheel = backend.build_wheel(metadata, build_script=tool_config.poetry.build)

Key design aspects:

  • Single source of truth — all configuration in one file
  • Declarative metadata — PEP 621 fields are parsed by any compliant tool
  • Optional extras — users install only what they need (e.g., [betfair] or [ib])
  • Tool-agnostic — ruff, mypy, pytest all read from [tool.*] sections

Related Pages

Page Connections

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