Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How poetry knows my package is located in the src folder?

I have a simple question.

I used to create a poetry project with my package at root.

project.toml
mypackage
  +- __init__.py
  +- mypackage.py
  +- test_mypackage.py

I recently moved my tests in another directory, so that the folder now looks like.

project.toml
src
  +- mypackage
      +- __init__.py
      +- mypackage.py
tests
  +- test_mypackage.py

Nothing changed for poetry which still work fine when I make poetry build. How does it search for the package root folder? Does it serach a folder with the package name in project.toml?

Thanks for your help.

like image 234
emonier Avatar asked Aug 31 '25 15:08

emonier


1 Answers

Having a folder called src to contain the package code is just a pre-defined standard that poetry recognizes without being told. It works via the packages section in your project file, which by default scans for mypackage and src/mypackage. If you provide your own value, it will stop auto-detecting those two.

like image 57
Arne Avatar answered Sep 13 '25 12:09

Arne