[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's the latest best practice on Python project directory layouts?

I have a collection of command line scripts that share a collection of common modules. This code collection is for internal use and will run under a single version of Python 3.6+ and a single OS. My understanding of best practice is to organize this collection of Python files into a folder structure like this:

# common files
requirements.txt  <--- what is the advantage of this file for internally distributed code bases?

# app specific package folders
app-1 (optional; if needed)

app-2 (optional; if needed)

# modules shared across multiple apps

# tests - place at package level with sub-packages for each package -OR- underneath each app package?

# virtual env folder placed at same level as packages ???
    <virtual-env files go here>

And execute each app via the following ...

python -m app-1 <optional-parameters ...>


1. Does the above structure sound reasonable?
2. Where to place virtual env files and what to call this folder? venv, .env, etc?
3. Where to put tests (pytest)? In a tests folder or under each package?
4. Use a src folder or not? If so, where to put above files relative to the src folder?