You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
idea: "import hook" automatically installed with editable buildsΒ #1974
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...
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.
Activity
mbway commentedon 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)
where I'm thinking the site subcommand could be passed
install,infoanduninstallfor managing injecting the call tomaturin_import_hook.install()into thesite-packages/sitecustomize.pyof the current environment. Or the user can add calls tomaturin_import_hook.install()directly in each script that needs it if they prefer.the installation of
maturin_import_hookand optional injection into sitecustomize could also (optionally?) be done throughmaturin developlike you suggest.