{"id":19741932,"url":"https://github.com/pyo3/maturin-import-hook","last_synced_at":"2025-09-03T14:43:42.038Z","repository":{"id":225813756,"uuid":"743857548","full_name":"PyO3/maturin-import-hook","owner":"PyO3","description":"Import hook for maturin","archived":false,"fork":false,"pushed_at":"2025-02-19T01:20:43.000Z","size":432,"stargazers_count":9,"open_issues_count":5,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-03T10:41:54.469Z","etag":null,"topics":["import-hooks","maturin"],"latest_commit_sha":null,"homepage":"https://maturin.rs/import_hook","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PyO3.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":"Contributing.md","funding":null,"license":"license-apache","code_of_conduct":"Code-of-Conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-16T06:16:46.000Z","updated_at":"2025-02-19T01:20:47.000Z","dependencies_parsed_at":"2024-03-04T13:28:08.339Z","dependency_job_id":"ec5c7d7b-494c-451b-af8e-71f26693a9b2","html_url":"https://github.com/PyO3/maturin-import-hook","commit_stats":null,"previous_names":["pyo3/maturin-import-hook"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyO3%2Fmaturin-import-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyO3%2Fmaturin-import-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyO3%2Fmaturin-import-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyO3%2Fmaturin-import-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PyO3","download_url":"https://codeload.github.com/PyO3/maturin-import-hook/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251653966,"owners_count":21622229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["import-hooks","maturin"],"created_at":"2024-11-12T01:28:28.733Z","updated_at":"2025-04-30T06:30:49.250Z","avatar_url":"https://github.com/PyO3.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Maturin Import Hook\n\nA python import hook to automatically rebuild [maturin](https://www.maturin.rs/) projects and import stand-alone rust files.\n\nUsing this import hook reduces friction when developing mixed python/rust codebases because changes made to rust\ncomponents take effect automatically like changes to python components do.\n\nThe import hook also provides conveniences such as\n[importlib.reload()](https://docs.python.org/3/library/importlib.html#importlib.reload) support for maturin projects.\n\nDocumentation can be found at [maturin.rs](https://www.maturin.rs/import_hook).\n\n## Usage\n\nAfter installing [maturin](https://www.maturin.rs/installation), install the import hook into a python virtual\nenvironment with:\n\n```shell\npip install maturin_import_hook\n```\n\nThen, optionally make the hook activate automatically with:\n\n```shell\npython -m maturin_import_hook site install\n```\n\nThis only has to be run once for each virtual environment.\n\nAlternatively, put the following at the top of each python script where you want to use the hook:\n\n```python\nimport maturin_import_hook\n\n# install the import hook with default settings.\n# this call must be before any imports that you want the hook to be active for.\nmaturin_import_hook.install()\n\n# when a rust package that is installed in editable mode is imported,\n# that package will be automatically recompiled if necessary.\nimport example_maturin_package\n\n# when a .rs file is imported a project will be created for it in the\n# maturin build cache and the resulting library will be loaded.\n#\n# assuming subpackage/my_rust_script.rs defines a pyo3 module:\nimport subpackage.my_rust_script\n```\n\nOnce the hook is active, any `import` statement that imports an editable-installed maturin project will be\nautomatically rebuilt if necessary before it is imported.\n\n## CLI\n\nThe package provides a CLI interface for getting information such as the location and size of the build cache and\nmanaging the installation into `sitecustomize.py`. For details, run:\n\n```shell\npython -m maturin_import_hook --help\n```\n\n## Debugging\n\nIf you encounter a problem, a good way to learn more about what is going on is to enable the debug logging for the\nimport hook. This can be done by putting the following lines above the import that is causing an issue:\n\n```python\n# configure logging if you haven't already (make sure DEBUG level is visible)\nlogging.basicConfig(format=\"%(name)s [%(levelname)s] %(message)s\", level=logging.DEBUG)\nmaturin_import_hook.reset_logger()\n\nimport some_package\n```\n\n## License\n\nLicensed under either of:\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](https://github.com/PyO3/maturin-import-hook/blob/main/license-apache)\n  or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n- MIT license ([LICENSE-MIT](https://github.com/PyO3/maturin-import-hook/blob/main/license-mit)\n  or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyo3%2Fmaturin-import-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyo3%2Fmaturin-import-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyo3%2Fmaturin-import-hook/lists"}