sizmailov / pybind11-stubgen

Generate stubs for python modules
Other
232 stars 47 forks source link

Generate stubs before install myModule #79

Closed nyckmaia closed 2 years ago

nyckmaia commented 2 years ago

Hi, I'm a newer in Python stubs.

Today I compile my C++ code to a Python Module using Pybind11. If I understood how it works, to use pybind11-stubgen myModule MUST BE already installed in a Python environment, right?

If yes, so I have to follow these steps below:

Right?

I would like to automatize this process and generate the stubs BEFORE run my module installation setup.py. If is possible, it will enable to run setup.py once and get both myModule and myModuleStubs installed at the same time.

Question

Is there a way to do that?

Thank you,

sizmailov commented 2 years ago

Hi!

Thanks for the question.

MUST BE already installed in a Python environment, right?

Yes, it must be available, but it might be installed via pip --install ., i.e. without creating a distribution. This can be an intermediate step of your CI pipeline.

Once stubs are generated, you are can package them for distribution as described in PEP 561 (don't forget to include py.typed file to indicate that package provides stubs).

I don't have a simple example of my own projects. But maybe you will this ci snippet that uses pybind11-stubgen wrapper helpful.