*.pyi files not included when building a package #10082
-
I am writing a library/python package which uses some auto generated types generated from google's protobuf types. The google protobuf compiler also provides .pyi stub files for those types, since it uses dark magic to generate the actual classes. I include those in the code of my library, but poetry when building the packages seems to ignore all *.pyi files. According to the docs https://typing.readthedocs.io/en/latest/guides/libraries.html#providing-type-annotations it should be fine to provide *.pyi type stubs with the code, mixed with inline type hinting for other files, so type checkers understand the types. I don't want to create a separate stubs package as almost all my code has inline type definitions. Its only in 2 files with auto generated code where i need separatre stub files. I did a quick test, and if I manually copy the .pyi files to my (poetry) virtual env where I installed the library, then pyright picks up the type definitions just fine. So type checkers behave with a mix of inline type information and stub files just fine, but how do i make sure poetry actually includes the .pyi files? My library structure:
For some reason the .pyi file is not included in the files produced with poetry build and poetry publish. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
It should be as easy as [tool.poetry]
include = ["*.pyi"]
# or, if your wheel building process doesn't include the pyi files compilation
include = [
{ path = "*.pyi", format = ["sdist", "wheel"] }
] |
Beta Was this translation helpful? Give feedback.
-
Hey @dolfandringa, I cannot reproduce it. fin swimmer |
Beta Was this translation helpful? Give feedback.
-
@finswimmer Never contribute to malice (or bad engineering) what can be contributed to stupidity..... Sorry for the noise guys. Maybe a small sentence somewhere in the docs about pyi files and what is included in built (wheel/sdist) packages (basically everything, also my .proto files are in there) would be nice somewhere, but basically it was just me being stupid. What also fed the red herring was that I did see some discussion on the setuptools repo regarding including pyi files in packages, while this in hindsight obviously "just works" with poetry. |
Beta Was this translation helpful? Give feedback.
Hey @dolfandringa,
I cannot reproduce it.
*.pyi
should be included in sdist and wheel by default. Can you create a github rep with a project where we can reproduce it? Which version of Poetry do you use?fin swimmer