Namespace stub-only packages can't be built with Poetry
See original GitHub issue- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: Ubuntu 21.04
- Poetry version: 1.1.11
- Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/henribru/41eb19fdbb6a506affbd4b7e144148ef
Issue
PEP561 was recently updated to clarify how to structure stub-only packages for distributions that use namespace packages: https://github.com/python/peps/pull/2083
To summarize, the namespace packages should not have py.typed
and __init__.pyi
, these should be further down the directory tree in the actual packages. Poetry doesn’t support building stub-only packages with this structure, you end up hitting this exception: https://github.com/python-poetry/poetry-core/blob/master/poetry/core/masonry/utils/package_include.py#L83
The reason is that this check is too strict: https://github.com/python-poetry/poetry-core/blob/master/poetry/core/masonry/utils/package_include.py#L49-L54
It expects each file to be either a py.typed
in the root or a .pyi
, which doesn’t hold if you have one or more py.typed
files further down the tree. Seems like simply removing the el.parent.name == self.package
check would fix this issue, so I’d be happy to do a PR for that (though I’m not sure that it’s invalid for stub-only packages to include other file types so the check might still be a bit strict).
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
From my understanding it’s installed as an entirely separate package and pip and Poetry don’t know that
pandas
andpandas-stubs
are related. But your typechecker knows they are so it looks forpandas-stubs
to typecheckpandas
.@BrenoJesusFernandes That should probably be its own issue but:
pandas
is insidetypings
, but it’s actually just directly in the root?pandas
but stub-only packages need to have a-stubs
suffix