halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.83k stars 1.07k forks source link

Code completion with Python bindings? #8112

Open ziriax opened 6 months ago

ziriax commented 6 months ago

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.

steven-johnson commented 6 months ago

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 :-)

lirenzhucn commented 3 months ago

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.

steven-johnson commented 3 months ago

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.