Skip to content

idea: "import hook" automatically installed with editable buildsΒ #1974

Description

@davidhewitt

I was thinking about "editable" / dev installs today and it struck me, should we support automatically installing the import hook for pip install -e editable installs?

It would be quite nice if maturin-backed packages installed in editable mode automatically used the import hook. I think it would be possible by putting the hook installation in a .pth file. Maybe once in maturin's .pth, and then the hook can work out what packages have been installed in editable mode / whether to recompile?

That could be an interesting trick to make local development of Rust packages more seamless for those not used to compiling...

Activity

  1. mbway commented on Feb 28, 2024

    @mbway
    Contributor

    not strictly related to the suggestion but I'm working on a new import hook here https://github.com/mbway/maturin-import-hook (which was originally here #1748).

    Unlike the existing import hook, the new one supports detecting when rebuilds are necessary (including following path dependencies) and supports importlib.reload() (except on Windows right now).

    It's not 100% finished but my idea for the workflow would be that for each virtualenv that you want to have the import hook available for you would run (once)

    $ pip install maturin_import_hook
    $ python -m maturin_import_hook site install
    

    where I'm thinking the site subcommand could be passed install, info and uninstall for managing injecting the call to maturin_import_hook.install() into the site-packages/sitecustomize.py of the current environment. Or the user can add calls to maturin_import_hook.install() directly in each script that needs it if they prefer.

    the installation of maturin_import_hook and optional injection into sitecustomize could also (optionally?) be done through maturin develop like you suggest.

  2. added theissue type on Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions