Halide icon indicating copy to clipboard operation
Halide copied to clipboard

Code completion with Python bindings?

Open ziriax opened this issue 1 year ago • 3 comments

I was trying out the Python bindings using Ubuntu 23.10 and the Halide16 apt packages in a Docker container with a VSCode remote connection, but I wasn't able to get code completion working.

My code did run fine, it was just the VSCode IDE that showed all kinds of errors because it didn't find the halide symbols.

Is this supposed to work correctly, or is this not supported.

ziriax avatar Feb 19 '24 22:02 ziriax

I'm not aware that any of the Halide core contributors have ever looked into making this work, so, yeah, it's probably nt working.

We'd be happy for someone else to do so and submit a PR, of course :-)

steven-johnson avatar Feb 19 '24 22:02 steven-johnson

I was doing some quick experimentation just today on this! In short, pybind11 generated python bindings don't work with standard Python tools like pyright (VSCode's default lsp) or mypy.

I tried pybind11-stubgen with some success. Basically, after installing it, you run something like:

pybin11-stubgen halide -o path/to/site-packages

Assuming halide is installed under path/to/site-packages.

This will generate a few .pyi stub files and place them next to the installed halide files. Many things are still not working, though. But based on a quick look at this discussion on pybind11, some tweaks in halide's python bindings code will really help.

lirenzhucn avatar May 28 '24 03:05 lirenzhucn

some tweaks in halide's python bindings code will really help.

At the moment we don't have any resources available to work on this, but we'd be very happy to review any PRs that improve the Python bindings.

steven-johnson avatar May 28 '24 16:05 steven-johnson