How can I create .pyi
files from cython source code (.pyx
)?
Create .pyi file automatically from cython source?
Asked Answered
You can use the cythonbuilder package for that, https://pypi.org/project/cythonbuilder/
- Install cythonbuilder:
pip install cythonbuilder
- Use the command
cythonbuilder.exe build -y
to automatically build all .pyx file in current working directory and generate .pyi files.
CythonBuilder did not fit naturally into my setup.py files. It needed some modification to support some cython types. All the parsing code is located in: github.com/mikehuls/cythonbuilder/blob/main/cythonbuilder/… It does not support all cython syntax but it was workable with a few updates. Eventually, I created my own parser with pyparsing. It is a bit overkill for creating stub files but allows for modifications. It supported most of cython stub related syntax. github.com/RaubCamaioni/CythonPEG/blob/main/cython_peg.py –
Nicotiana
Amazing work! ~~filler text to post comment~~ –
Gasholder
© 2022 - 2024 — McMap. All rights reserved.
cybuilder build
command generates pyi by default. Maybe you can write an answer to this unanswered question?:) – Whipperin