Python Project Layout: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 8: Line 8:
  ├─ .gitignore
  ├─ .gitignore
  ├─ requirements.txt
  ├─ requirements.txt
├─ run
  ├─ src
  ├─ src
  │  └─ main
  │  └─ main

Revision as of 00:49, 18 February 2022

Internal

Overview

A typical Python project layout, which allows for code written in other programming languages as well, is similar to:

.
├─ .gitignore
├─ requirements.txt
├─ run
├─ src
│   └─ main
│       └─ python 
│           └─ main.py
└─ venv # created automatically upon virtual environment initialization
     ├─ bin
    ...

Setting a Manual Project

Add the dependencies to requirements.txt. For more details, see:

requirements.txt

Initialize the virtual environment:

cd ${PROJECT_HOME}
python3 -m venv venv
venv/bin/pip install -r ./requirements.txt

For more details on virtual environments, see:

Virtual Environment

Example of .gitignore:

venv/