scikit-build / scikit-build-core

A next generation Python CMake adaptor and Python API for plugins
https://scikit-build-core.readthedocs.io
Apache License 2.0
223 stars 47 forks source link

Inclusion of stub files #713

Open ThoreWietzke opened 4 months ago

ThoreWietzke commented 4 months ago

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.

ThoreWietzke commented 4 months ago

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

henryiii commented 4 months ago

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.

ThoreWietzke commented 4 months ago

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.