Reputation: 63172
I have structured our python project in a typical manner:
project root
|--src
|--my_pkg
-- my_module.py
--__init__.py
|--tests
I have followed poetry docs for include/exclude
Based on that I added the following to pyproject.toml
:
[tool.poetry]
..
include = ["src/*"]
But i get
ValueError
my_pkg is not a package.
How can I tell poetry
to look under src
for the my_pkg.my_module
?
Upvotes: 2
Views: 2994
Reputation: 8585
I'm building an AWS Lambda function, so my source directory is pretty bare-bones:
src
├── foo.py
└── bar.py
I've found that I need this in my pyproject.toml
:
[tool.poetry]
name = "baz"
packages = [ { include = "*.py", from = "src" } ]
Note: no mention of the package name in the packages
entry.
Upvotes: 1
Reputation: 15202
Don't put a __init__.py
in the src
folder. There's no need for it.
If you have this in your pyproject.toml
[tool.poetry]
name = "my-pkg"
Poetry will find my_pkg
in the src
automatically. But you can be more explicit by:
[tool.poetry]
# ...
packages = [
{ include = "my_pkg", from = "src" },
]
See https://python-poetry.org/docs/pyproject/#packages
Upvotes: 2