Standard project structure not specified or not easily findable
See original GitHub issue- I have searched the issues of this repo and believe that this is not a duplicate.
Issue
When Poetry is unable to determine the packages of the current project (folder). It prints an error such as:
[ModuleOrPackageNotFound]
No file/folder found for package <package>
When a user then tries to find something about this error on the web he will find some closed issues talking about the packages
portion of the pyproject.toml
. There and in some other locations (e.g. GitHub) you can find “If your project structure differs from the standard one supported by poetry…”. However, it is not defined (or will not pop up in search results) defined, as far as I can see, what exactly this standard structure might be.
By looking at https://python-poetry.org/docs/basic-usage/ one might guess what it could be.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:27
- Comments:19 (8 by maintainers)
Top Results From Across the Web
Java project folder structure in IntelliJ IDEA - Stack Overflow
Either way the sources folders have not been configured correctly. Just open up the project structure window (file -> project structure) and ...
Read more >Structuring Your Project - The Hitchhiker's Guide to Python
In practical terms, “structure” means making clean code whose logic and dependencies are clear as well as how the files and folders are...
Read more >File Structure : Broad Institute of MIT and Harvard
File structures are not fixed entities, but rather build a framework that communicates the function and purpose of elements within a project by...
Read more >How to Structure a Data Science Project for Readability and ...
It is important to structure your data science project based on a certain standard so that your teammates can easily maintain and modify...
Read more >Project Setup - MATLAB & Simulink - MathWorks
Organize work into projects, automate startup and shutdown, find frequent ... In a project, use templates to create and reuse a standard project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For a project like this, clear documentation is almost as important as working functionality. Documentation that says “If your project structure differs from the standard one supported by poetry” without ever once explaining the “standard one supported by poetry” seems like clearly buggy documentation. (Very much understood that bugs and work need prioritizing and not everything can be fixed right away, but the first step is for us all to realize that this is a bug as serious as a code bug.)
I feel like there used to be a page explaining the project layouts supported by Poetry. Am I imagining things?
My current understanding is:
In my humble opinion, this all makes reasonable sense, but is very badly underdocumented, leading to confusion and anger:
I’m heartened that @HallerPatrick has started a PR, though it only takes a little nibble at this issue and also seems stalled.
@egnor 's comment above is on point with the issue at hand, and gives a good explanation of what is wrong. What I think should be done to fix the documentation is to include a section within the ‘Basic Usage’ section that explicitly outlines the intended folder structure for the package, even if that is redundant with other documentation.
This means briefly explaining the distinction between package vs. project, breaking down where exactly key files should be in relation to eachother (ie, “your entry point should be in a package folder directly underneath where pyproject.toml is located”), and more clearly reference the documentation in itself (ie, the “Basic Usage” chapter mentions pyproject.toml, but it is not a link, leaving the user to navigate through documentation manually. This is bad practice.) Furthermore, within the pyproject.toml.
The reason for the redundancy and clarifications is that the tone of the documentation assumes a certain degree of pre-existing knowledge of python packaging that just doesn’t exist in the community. As others have stated, packaging in python is notoriously obtuse, poorly-documented, and complex, and the PEPs themselves don’t provide enough documentation to either establish best practice or even a competent baseline understanding of the process. In addition to that, documentation that assumes advanced prior knowledge is just plain bad documentation.
This aspect of documentation shows an area where it just is not explicit enough and not every user of poetry has the time to investigate the source files to find a solution to what should be a simple problem.
In my personal experience, I cannot get my program to run because I keep getting
ModuleNotFoundError
which is directly caused by me not being able to figure out how exactly Poetry wants tool.poetry.packages and tool.poetry.scripts to be formatted. Yes, the syntax is there, but there is no documentation in any resource, poetry or Python itself which explains “tool.poetry.packages expects your entry point to be in this particular folder relative to pyproject.toml” or “tool.poetry.scripts looks through the listed packages in this manner to find the entry point you declared”.Finally, there is one more addition that could improve this problem:
poetry check
could be improved by testing the declared scripts entry point for ModuleNotFoundError, and return a warning that the entry point may not work.