Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
davidhewitt opened this issue Feb 28, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@davidhewitt
Copy link
Member

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...

@davidhewitt davidhewitt added the enhancement New feature or request label Feb 28, 2024
@mbway
Copy link
Contributor

mbway commented Feb 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants