Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
geryogam opened this issue Sep 15, 2019 · 5 comments · Fixed by #1592
Closed
1 task done

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

geryogam opened this issue Sep 15, 2019 · 5 comments · Fixed by #1592
Assignees
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected
Milestone

Comments

@geryogam
Copy link
Contributor

geryogam commented Sep 15, 2019

  • 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.

@geryogam
Copy link
Contributor Author

FYI @sdispater, @brycedrennan.

@sdispater sdispater added kind/bug Something isn't working as expected area/build-system Related to PEP 517 packaging (see poetry-core) labels Sep 20, 2019
@sdispater sdispater added this to the 1.0 milestone Sep 20, 2019
@kasteph kasteph self-assigned this Oct 18, 2019
@finswimmer
Copy link
Member

finswimmer commented Nov 1, 2019

Hello,

that's the code that is responsible for this:

https://github.com/sdispater/poetry/blob/8fd63110b8de2479f3d65a86209ade65c788d96a/poetry/masonry/utils/package_include.py#L37-L63

So, whenever a glob is used, the poetry builder expect to find a __init__.py in the list of files after expanding the wildcards. But it doesn't expect one if only one specific folder or file is given.

To fix this issue, it is necessary to define the expected behavior. Is one allowed to include module files only? If a package should be included, is a __init__.py necessary (which isn't for python version >= 3.3)?

fin swimmer

@finswimmer
Copy link
Member

@sdispater , @stephsamson: I would like to work on that, but need some guidance/decision about what should actually get included if the packages option is used.

Would be nice if you find some time to discuss this :)

@kasteph
Copy link
Member

kasteph commented Nov 3, 2019

@finswimmer thanks for volunteering to work on this issue :) I am already currently working on this ticket actually which is why this has been self-assigned but there are other bugs in the low priority lane here which need help!

But indeed you are right, the work necessary to be done is in package_include and include. Both of them have functional tests but no unit tests which may be one reason why this issue was not caught in the first place until reported.

kasteph added a commit that referenced this issue Jan 6, 2020
sdispater pushed a commit that referenced this issue Jan 7, 2020
…1592)

* Handle nested wildcards in package includes correctly. Fixes: #1379.

Use compat `Path`.

* Ensure that when building sdists, subpackages with Python files (but not necessarily an __init__.py file) will be included.
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants