Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

No file/folder found for package my-python-lib when performing poetry build #8324

Unanswered
smarri4 asked this question in Q&A
Discussion options

I have a project structure like below which I also created using poetry:

my-python-lib
|──  my_python_lib
│            |── __init__.py
│            |── app.py
|── README.md
|── __init__.py
|── poetry.lock
|── pyproject.toml
|── report.xml
|── tests
         |── __init__.py
        └── test_app.py

---------------------------------
 git:(main*) $ poetry --version
Poetry (version 1.5.1)
---------------------------------
 git:(main*) $ poetry build
Building my-python-lib (0.1.0)

No file/folder found for package my-python-lib

pyproject.toml

[tool.poetry]
name = "my-python-lib"
version = "0.1.0"
description = "A python library sample"
authors = ["redacted"]
license = "\"Redacted\""
readme = "README.md"
packages = [{include = "my_python_lib", format = "wheel"}]

[tool.poetry.dependencies]
python = "3.11.4"
...
requests = "^2.31.0"


[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

I've referred to this issue: #512 and discussion: https://github.com/orgs/python-poetry/discussions/7564 , but it does not solve the error that I am facing. Can someone tell what I am doing wrong. Do the project name and the package name have to be the same?

You must be logged in to vote

Replies: 4 comments · 1 reply

Comment options

I went ahead and added print statements to the poetry core masonry module.py, looks like it doesn't get the packages included in the pyproject.toml. It prints them as empty:
image

git:(main*) $ poetry build -v
Using virtualenv: /Users/<user>/Library/Caches/pypoetry/virtualenvs/my-python-lib-hUq4-ovD-py3.11
Building my-python-lib (0.1.0)
my_python_lib   /Users/<user>/code/my-python-lib False [] [] []

  ModuleOrPackageNotFound

  No file/folder found for package my-python-lib

  at venv/lib/python3.11/site-packages/poetry/core/masonry/utils/module.py:71 in __init__
       67│                             "from": str(src.relative_to(self._path)),
       68│                         }
       69│                     ]
       70│                 else:
    →  71│                     raise ModuleOrPackageNotFound(
       72│                         f"No file/folder found for package {name}"
       73│                     )
       74│ 
       75│         for package in packages:
You must be logged in to vote
0 replies
Comment options

I am not sure why you have it like this, but in /poetry/core/masonry/builders/builder.py, its written in a way that poetry build wont work if format is specified like I did packages = [{include = "my_python_lib", format = "wheel"}] because of the below code:

            if (
                    formats
                    and self.format
                    and self.format not in formats
                    and not ignore_packages_formats
            ):
                continue

I am looking to see if there is a workaround, but this seems like pretty basic mistake

You must be logged in to vote
0 replies
Comment options

Make sure you name your package with underscores instead of hyphens, so: my_python_lib and also refer to it as such in your *.toml file.

You must be logged in to vote
1 reply
@dezza
Comment options

This is a very important detail, for others with similar issue!

Do not use - in package name or entry-points or you'll be stuck here.

Comment options

I second that, what @smarri4 said, I hit the same problem. I removed format = "wheel" from there and it worked.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.