Implementation:Pola rs Polars Polars Python Cargo Config
| Knowledge Sources | |
|---|---|
| Domains | Build_System, Python_Bindings |
| Last Updated | 2026-02-09 09:00 GMT |
Overview
Concrete tool for configuring the polars-python crate's dependencies, feature flags, and Python binding options provided by the Cargo build system.
Description
The polars-python/Cargo.toml manifest defines the build configuration for the Python bindings crate. It depends on 17 internal polars crates (polars-core, polars-lazy, polars-io, etc.) plus external dependencies including pyo3 (with abi3-py310 stable ABI), numpy for ndarray interop, ndarray for n-dimensional array support, and platform-specific allocators (tikv-jemallocator on Unix, mimalloc on Windows/Emscripten). The feature system is organized into four tiers: dtypes (8 optional data types), operations (30+ compute operations), io (8 I/O formats including cloud), and optimizations (CSE, fused operations). The full feature activates all production capabilities. Three runtime features (rt32, rt64, rtcompat) control the index size for different wheel variants.
Usage
This manifest is consumed by the Cargo build system when compiling the polars-python crate. Developers modify it to add new features exposed to Python, update dependencies, or configure platform-specific behavior. The feature flags directly correspond to functionality available in the Python polars package.
Code Reference
Source Location
- Repository: Pola_rs_Polars
- File: crates/polars-python/Cargo.toml
- Lines: 1-321
Signature
[package]
name = "polars-python"
description = "Enable running Polars workloads in Python"
[dependencies]
pyo3 = { features = ["abi3-py310", "chrono", "chrono-tz", "multiple-pymethods"] }
numpy = { workspace = true }
# ... 17 internal polars crates
[features]
default = ["full"]
full = ["async", "pymethods", "optimizations", "io", "operations", "dtypes", ...]
rt32 = [] # Standard 32-bit index
rt64 = ["polars/bigidx"] # 64-bit index
rtcompat = ["polars/bigidx"] # Compatibility mode
Import
# Referenced in py-polars/runtime/*/Cargo.toml as:
[dependencies]
polars-python = { path = "../../polars-python", features = [...] }
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Feature flags | Cargo features | No | Enable specific functionality (io, operations, dtypes, etc.) |
| Runtime variant | rt32/rt64/rtcompat | Yes | Selects the index size for the wheel build |
Outputs
| Name | Type | Description |
|---|---|---|
| cdylib | Shared library | The compiled Python extension module (via polars-dylib) |
| Python API | PyO3 bindings | Full Polars API accessible from Python |
Usage Examples
Enabling Features for Development
# Build with only CSV and Parquet support
cargo build -p polars-python --no-default-features --features="csv,parquet,pymethods"
# Build with full features
cargo build -p polars-python --features="full"