pybind11-stubgen icon indicating copy to clipboard operation
pybind11-stubgen copied to clipboard

Where to store the generated stubs?

Open phcerdan opened this issue 1 year ago • 5 comments
trafficstars

I have generated stubs for a pip installed module (generated with pybind11) to aid with development.

I have pyright as my Language Server Protocol (LSP). Where should I put the generated stubs for pyright (or any other LSP) to read them?

Thanks!

phcerdan avatar Nov 26 '23 20:11 phcerdan

I have the following directory structure:

./rpydemo/
./rpydemo/py.typed
./rpydemo/_rpydemo.cpython-311-x86_64-linux-gnu.so
./rpydemo/_rpydemo/
./rpydemo/_rpydemo/__init__.pyi

virtuald avatar Nov 26 '23 22:11 virtuald

Do you have an example library where you run stub generation during the building process (pip install .)? I have this project, and I would like to somehow get the generator to run and install the stub with the library. I assume there should be some way to achieve this either in the pyproject.toml or setup.py?

5had3z avatar Nov 27 '23 01:11 5had3z

@5had3z see https://github.com/sizmailov/pybind11-stubgen/issues/104#issuecomment-1706128213

sizmailov avatar Nov 27 '23 01:11 sizmailov

@5had3z see #104 (comment)

I'm able to get it in a single pass here with my additional flag.

5had3z avatar Nov 27 '23 05:11 5had3z

@sizmailov is it bad idea to put stubs directly to the same directory? With:

pybind11-stubgen -o ...my_env/lib/python3.11/site-packages/ --root-suffix "" <lib_name>

martincerven avatar Jun 19 '24 07:06 martincerven