Compilation of PYX (cython) -> PYI (stub) file converters.

674 views
Skip to first unread message

Raub Camaioni

unread,
Aug 6, 2023, 12:37:21 AM8/6/23
to cython-users
This discussion contains a compilation of PYX->PYI file conversion method. 
Please post links to additional code/methods for PYX -> PYI conversion. 

Marc Weber

unread,
Apr 22, 2025, 12:25:42 AMApr 22
to cython-users
i have done some unfinished work parsing comments here:
https://github.com/MarcWeber/py-create-stubs
But there is much work missing cause even parsing the comments isn't enough because some arguments are not marked optional.
So while its better than nothing making it perfect will require much more time/work. How does it work ? I implemented a parser which
can read stubs also with c like annotations trying to turn them into Python types. So the ARGS:  ARGS\n===== like parts of comments
get read and understood often. There are many exceptions and a view types in codes such as older cupy I looked into. The idea is to automate 
what can be automated and add some rules so that type stubs for the version you're using can be derived.
The links in your post mainly focus on understanding the signatures only but most information actually is found in comments for cupy/cuda.
the  experiment1.py actually creates some stubs. And test-cython-parser.py shows that cython could be used but is unfinished.
It lists the classes and (c)defs already like the links above.
Reply all
Reply to author
Forward
0 new messages