--- id: maturin-import-hook version: "0.3.0" license: unclear license_treatment: permissive maintenance: active --- # maturin-import-hook — Import hook to load rust projects built with maturin License: permissive · Maintenance: active · Downloads: 99.1K/mo ## 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 above — 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 pip install maturin-import-hook uv add maturin-import-hook poetry add maturin-import-hook ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 99.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags maturin import hook, rust python import, automatic rust rebuild, maturin development workflow, mixed python rust development, pyo3 import automation, rust file import python, rust-python-interop, development-workflow, import-hook [View on SkillFed](https://skillfed.io/packages/maturin-import-hook) · [View on PyPI](https://pypi.org/project/maturin-import-hook/)