maturin-import-hook
Import hook to load rust projects built with maturin
What it is and what it does
Maturin Import Hook is a Python import hook that intercepts imports of Rust projects built with maturin and automatically recompiles them if their source has changed. It bridges the development experience gap between Python and Rust by making Rust changes take effect on import, just like Python code does. The hook works in two modes: it can rebuild editable-installed maturin packages on import, or compile standalone .rs files into temporary projects in a build cache. This reduces friction when working on mixed Python/Rust codebases by eliminating manual rebuild steps.
The package integrates into Python's import system and can be activated either globally or per-script by calling maturin_import_hook.install(). It requires maturin to be installed separately and depends on filelock and tomli for its own operation. The hook also supports importlib.reload() for recompiling projects during development and includes a CLI for managing the build cache and installation state.
Use it for:
- Developing a Python package with Rust extensions where you want Rust changes to take effect immediately on re-import without manual rebuilds.
- Writing standalone .rs files as importable modules in a Python project to test or prototype Rust code without a full package structure.
- Iterating on performance-critical Python functions by rewriting them in Rust and testing them in the same development loop.
- Managing a monorepo with multiple editable-installed maturin packages that need to rebuild on demand during active development.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically rebuilds Rust components in maturin projects during Python imports, eliminating the need to manually recompile when Rust code changes.
Yes, if you are actively developing mixed Python/Rust code with maturin. The low install friction, permissive licensing, active maintenance, and zero known vulnerabilities make it a safe choice. The import hook genuinely reduces development friction by automating rebuilds. Not necessary if you are only consuming pre-built Rust extensions or not using maturin.
Install
maturin-import-hook on PyPI
pip
pip install maturin-import-hookuv
uv add maturin-import-hookpoetry
poetry add maturin-import-hookInstalling maturin-import-hook
Before you install
Low friction install with only filelock and tomli as runtime dependencies. Actively maintained with recent releases; last commit on 2026-07-11.
License in practice
Dual-licensed under Apache 2.0 or MIT at your option—both permissive licenses with no copyleft obligations, making it safe for commercial and proprietary projects.
Quickstart
pip install maturin_import_hook
import maturin_import_hook
maturin_import_hook.install()
# Rust changes now rebuild automatically on import
Requires maturin to be installed separately; Python >= 3.9 required.
Verify before relying
- Whether the hook works with all maturin project configurations or has known limitations with certain build setups.
- Performance impact of automatic rebuilds on large Rust codebases during development.
- Compatibility with different Python virtual environment managers beyond standard venv.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — filelock, tomli |
| Maintenance | actively maintained — 432 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 99,072/month — #13,040 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: maturin_import_hook-0.3.0-py3-none-any.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
maturinMaturin builds and publishes Python packages…
permissive · top 5,000 on PyPI
puccinialinInstalls Rust and Cargo into a temporary cache…
permissive · top 5,000 on PyPI
moviepilot-rustProvides Rust-accelerated parsing and filtering…
unclear · top 15,000 on PyPI
setuptools-rustsetuptools-rust is a setuptools plugin that…
permissive · top 5,000 on PyPI
delta-kernel-rust-sharing-wrapperProvides Python bindings to the Rust-based…
permissive · top 5,000 on PyPI
rustworkxA high-performance graph library for Python,…
permissive · top 5,000 on PyPI
ignore-pythonProvides fast recursive directory traversal…
unclear · top 15,000 on PyPI
chia-rsProvides Python bindings to Rust crates for…
unclear · top 15,000 on PyPI
hogql-parser-rsParses HogQL query expressions into JSON AST…
permissive · top 5,000 on PyPI