scikit-build/scikit-build-core

Inclusion of stub files

ThoreWietzke opened this issue · 3 comments

Hello,

scikit build core has helped me a lot in packaging and building my C++ extensions. Currently I'm struggling a bit where to place my stub files (*.pyi) to ship type hints and docstrings for extension.

I organize the code inside src and include with several subfolders to keep the files organized. I tried placing it directly in src, src/{package_name}, python and python/{package_name}, but it doesn't show up inside my site-packages in my environment?

So where do I have to place the stub so it will be picked up correctly? Do I need further settings like

[tool.scikit-build]
wheel.packages = ["python/src/mypackage"]

inside my pyproject.toml?

Further information: I use CMake and pybind11 for my extension.

I found my issue ... I forgot to include the __init__.py file ...

An example is https://github.com/scikit-hep/boost-histogram/tree/develop/src/boost_histogram/_core, which is a stub (directory) for boost_histogram/_core.so.

Thanks for that example. I also found the official documentation regarding stubs: https://typing.readthedocs.io/en/latest/source/stubs.html
I leave it here so anyone who has the same question can look it up.