Skip to content

tool.poetry.packages handles wildcards * and ** incorrectly in pyproject.toml #1379

@geryogam

Description

@geryogam
  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

The documentation gives the following example for using the tool.poetry.packages property of the pyproject.toml file:

[tool.poetry]
# ...
packages = [
    { include = "mypackage" },
    { include = "extra_package/**/*.py" },
]

However the command poetry build raises the following error when the "extra_package/**/*.py" path pattern matches multiple files/directories in at least one the of its path segments:

[ValueError]
/Users/maggyero/Desktop/project/extra_package/bar/baz.py is not a package.

with the following directory layout:

project
├── .git
├── mypackage
│   └── foo.py
├── extra_package
│   └── bar
│       ├── baz.py
│       └── qux.py
└── pyproject.toml

Here the last *.py path segment of the "extra_package/**/*.py" path pattern matches baz.py and qux.py, which triggers the ValueError. Deleting the project/extra_package/bar/qux.py file removes the ValueError. And adding a project/extra_package/quux directory raises the same ValueError, since this time the second ** path segment of the "extra_package/**/*.py" path pattern matches bar and qux. So it seems that matching multiple files/directories in the path segments of a path pattern is not allowed. It looks like a bug, because each item of the tool.poetry.packages list is supposed to include a single top-level module or package and optionally specific submodules (like "extra_package/**/*.py" which includes the top-level extra_package package and submodules that have a .py extension).

Also, since the tool.poetry.packages property of the pyproject.toml file can include both directories and files, that is to say both packages and non-package modules, I think we should rename to tool.poetry.modules.

Metadata

Metadata

Assignees

Labels

area/build-systemRelated to PEP 517 packaging (see poetry-core)kind/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions