PEP about recommended project folder layout

c.buhtz at posteo.jp c.buhtz at posteo.jp
Tue Jul 26 03:14:42 EDT 2022


Hello,

I am not sure if I looked into the correct sources. I was looking in 
"PEP 609 – Python Packaging Authority (PyPA) Governance" [1] and the 
"PyPA specifications" [2].

My question in short: Is there an official document (e.g. a PEP) about a 
recommended layout for project folders.

Looking into the wild and past there are a lot of variations of such 
layouts. I am far away from being a pro but depending on experience in 
my own projects and what I have learned from others (e.g. in 
blog-posts/tutorials) I recommend to have the "test" folder and the 
package folder side by side on the same level in the project folder (the 
root).

my_project
|- tests
|  └ test_*.py
|- my_package
|  └ __init__.py
└-- README.md

I sometimes add to it the so called "src"-Layout where the package 
folder is one level deeper in an extra "src" folder.

my_project
|- tests
|  └ test_*.py
|- src
|  └- my_package
|     └ __init__.py
└-- README.md

I don't want to discuss the pros and cons of all variations. What I need 
is an official document I can use in discussions with other maintainers. 
If there is a PEP/document against my current recommendation I am also 
fine with this. ;)

Kind
Christian

[1] -- <https://peps.python.org/pep-0609/>
[2] -- <https://packaging.python.org/en/latest/specifications>


More information about the Python-list mailing list