sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
218 stars 44 forks source link

Where to store the generated stubs? #201

Open phcerdan opened 7 months ago

phcerdan commented 7 months ago

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!

virtuald commented 7 months ago

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
5had3z commented 7 months ago

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?

sizmailov commented 7 months ago

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

5had3z commented 7 months ago

@5had3z see #104 (comment)

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

martincerven commented 3 weeks ago

@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>