How does one create micropython stubs of LVGL bindings for unix port?

I’ve been using the micropython stubs for 8.1 for a bit now, but recently changed to v9.

There are no stubs for v9 yet in the micropython-stubs collection:
https://micropython-stubs.readthedocs.io/en/main/packages.html

I do not quite understand how these stubs are created and if one can create them using the unix port?

The examples I see in the documentation rely on mpremote, which I cannot use on the unix port.

I do not know how to create them or even get started creating them, without reading dozens of documentations, just to piece together information that appears to be targeted mainly for specific hardware.

Ohhh that’s a tricky nut to crack right there. We started working on a way to do that. I am waiting for the PR to get merged and then I can begin the next steps of creating the stub files.

That script read all of the LVGL header files and puts together a map of the entire LVGL API into JSON format. This includes all types and names as well as all of the documentation that is in LVGL for the API. Using that I can build the stub file pretty easily.

Looks promising, unfortunately the script doesn’t work for me on Linux yet.

Traceback (most recent call last):
  File "/home/rini-debian/git-stash/lvgl/scripts/gen_json/gen_json.py", line 176, in run
    p = subprocess.Popen(
        ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'gcc -std=c11 -E -Wno-incompatible-pointer-types -o "/tmp/tmphy6hnwgb.lvgl_json/lvgl.pp" -DLV_LVGL_H_INCLUDE_SIMPLE -DLV_CONF_INCLUDE_SIMPLE -DLV_USE_DEV_VERSION -DPYCPARSER -I"/tmp/tmphy6hnwgb.lvgl_json/fake_libc_include" -I"/tmp/tmphy6hnwgb.lvgl_json" -I"/home/rini-debian/git-stash/lvgl" "/tmp/tmphy6hnwgb.lvgl_json/lvgl/lvgl.h"'

Looking through your script will take me a bit, might be an issue on my end.

Here you go.
Download the file and remove the “.txt” extension

lvgl.pyi.txt (459.0 KB)

Many, many thanks!

I’ll keep an eye on the PR, surely is a helpful addon to the repository, even though I couldn’t get it running for now.

You should consider adding it to the micropython stubs collection, I surely am not the only person looking out for it.

I literally generated that last night. I have not checked the consistency of it and I am sure you will report anything that is not correct.