stubgen: Allow file paths to extensions as inputs #924
nicholasjng
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey! I have a question / feature request regarding stubgen.
Right now, we invoke stubgen by running
python -m nanobind.stubgen -m my_ext
.This is a great way to generate stubs on the fly e.g. for installed packages, but for generating stubs in a source tree, for example during a wheel build, I think it would be sensible to also allow paths to the shared extension libraries.
Then,
python -m nanobind.stubgen -m path/to/my/ext[.abi3].so
could import the extension by canonicalizing the path to a module name (in its simplest form, this could be done by converting the input path to POSIX, and replacing forward slashes with dots), and then using importlib's facilities to import the file as a module.This would enable generating stubs by just pointing stubgen to a libfile, and even handle the multi-extension case in a shell by something like
find . -type f -name "*.so" | xargs python -m nanobind.stubgen -m
.Is that a scenario that you could see for stub generation? I'm happy to send a patch if there's interest.
Beta Was this translation helpful? Give feedback.
All reactions