python-poetry / python-poetry/poetry
Build error when packages format is set and inconsistent tree structure
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
-
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 (
-vvvoption). -
OS version and name: Ubuntu 20.04.3 LTS
-
Poetry version: 1.1.13
Issue
Hi , I am having some trouble trying to build my project with poetry.
I have following structure:
$ tree .
.
├── dist
│ ├── mypackage-0.1.0-py2.py3-none-any.whl
│ └── mypackage-0.1.0.tar.gz
├── pyproject.toml
└── src
└── foo
├── bar
│ └── __init__.py
└── __init__.py
With:
[tool.poetry]
name = "mypackage"
version = "0.1.0"
description = "For test"
authors = ["Ghiles Meddour"]
packages = [
{ include = "foo", from = "src" }
]
1 - Build error when packages format is set to a single value
With that poetry build works fine, but I have an error with:
packages = [
{ include = "foo", from = "src", format = "sdist" }
]
Or
packages = [
{ include = "foo", from = "src", format = "wheel" }
]
Gives:
$ poetry build -vvv
Using virtualenv: /home/user1/.cache/pypoetry/virtualenvs/mypackage-hFh4EyFE-py3.8
Building mypackage (0.1.0)
Stack trace:
7 ~/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py:131 in run
129│ parsed_args = resolved_command.args
130│
→ 131│ status_code = command.handle(parsed_args, io)
132│ except KeyboardInterrupt:
133│ status_code = 1
6 ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:120 in handle
118│ def handle(self, args, io): # type: (Args, IO) -> int
119│ try:
→ 120│ status_code = self._do_handle(args, io)
121│ except KeyboardInterrupt:
122│ if io.is_debug():
5 ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:171 in _do_handle
169│ handler_method = self._config.handler_method
170│
→ 171│ return getattr(handler, handler_method)(args, io, self)
172│
173│ def __repr__(self): # type: () -> str
4 ~/.poetry/lib/poetry/_vendor/py3.8/cleo/commands/command.py:92 in wrap_handle
90│ self._command = command
91│
→ 92│ return self.handle()
93│
94│ def handle(self): # type: () -> Optional[int]
3 ~/.poetry/lib/poetry/console/commands/build.py:36 in handle
34│
35│ builder = Builder(self.poetry)
→ 36│ builder.build(fmt, executable=self.env.python)
37│
2 ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/masonry/builder.py:35 in build
33│
34│ for builder in builders:
→ 35│ builder(self._poetry, executable=executable).build()
36│
1 ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/masonry/builders/builder.py:85 in __init__
83│ includes.append(include)
84│
→ 85│ self._module = Module(
86│ self._package.name,
87│ self._path.as_posix(),
ModuleOrPackageNotFound
No file/folder found for package mypackage
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/masonry/utils/module.py:63 in __init__
59│ "from": str(src.relative_to(self._path)),
60│ }
61│ ]
62│ else:
→ 63│ raise ModuleOrPackageNotFound(
64│ "No file/folder found for package {}".format(name)
65│ )
66│
67│ for package in packages:
Note that build works fine with format = ["sdist", "wheel"]
2 - Inconsistent tree structure
With:
packages = [
{ include = "foo", from = "src" }
]
I have:
$ unzip -l dist/mypackage-0.1.0-py2.py3-none-any.whl
Archive: dist/mypackage-0.1.0-py2.py3-none-any.whl
Length Date Time Name
--------- ---------- ----- ----
0 1980-01-01 00:00 foo/__init__.py
0 1980-01-01 00:00 foo/bar/__init__.py
87 2016-01-01 00:00 mypackage-0.1.0.dist-info/WHEEL
591 2016-01-01 00:00 mypackage-0.1.0.dist-info/METADATA
353 2016-01-01 00:00 mypackage-0.1.0.dist-info/RECORD
--------- -------
1031 5 files
$ tar tf dist/mypackage-0.1.0.tar.gz | tree --fromfile .
.
└── mypackage-0.1.0
├── PKG-INFO
├── pyproject.toml
├── setup.py
└── src
└── foo
├── __init__.py
└── bar
└── __init__.py
4 directories, 5 files
While, with:
packages = [
{ include = "foo", from = "src" , format = ["sdist", "wheel"] }
]
I have:
$ unzip -l dist/mypackage-0.1.0-py2.py3-none-any.whl
Archive: dist/mypackage-0.1.0-py2.py3-none-any.whl
Length Date Time Name
--------- ---------- ----- ----
0 1980-01-01 00:00 foo/__init__.py
0 1980-01-01 00:00 src/foo/bar/__init__.py
87 2016-01-01 00:00 mypackage-0.1.0.dist-info/WHEEL
591 2016-01-01 00:00 mypackage-0.1.0.dist-info/METADATA
357 2016-01-01 00:00 mypackage-0.1.0.dist-info/RECORD
--------- -------
1035 5 files
$ tar tf dist/mypackage-0.1.0.tar.gz | tree --fromfile .
.
└── mypackage-0.1.0
├── PKG-INFO
├── pyproject.toml
├── setup.py
└── src
└── foo
├── __init__.py
└── bar
└── __init__.py
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with poetry/_vendor/py3.8/poetry/core/masonry/utils/module.py and the build path shown in poetry/console/commands/build.py. Reproduce both package configurations with poetry build -vvv, then inspect the wheel and source archive contents. Done means single-value formats build successfully and the package tree remains consistent when both formats are specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100