Python Project Layout: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 28: Line 28:
  venv/bin/pip install -r requirements.txt
  venv/bin/pip install -r requirements.txt
</font>
</font>
For more details on virtual environments, see: {{Internal|Python_Language#Virtual_Environment|Virtual Environment}}


Example of <code>.gitignore</code>:
Example of <code>.gitignore</code>:
Example of <code>requirements.txt</code>:
<font size=-1>
<font size=-1>
  datadog == 0.43.0
  venv/
</font>
</font>
More details on <code>[[Pip#requirements.txt|requirements.txt]]</code>
{{Internal|Python_Language#Virtual_Environment|Virtual Environment}}


=Organizatorium=
=Organizatorium=

Revision as of 00:46, 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
├─ 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/

Organizatorium

  • /Users/ovidiu/Library/Python/3.8/bin/ must be in PATH.
  • Python environments on Mac:
    • ~/Library/ApplicationSupport/iTerm2/iterm2env/versions/*/bin/python3
    • ~/Library/ApplicationSupport/iTerm2/Scripts/YourScript/iterm2env/versions/*/bin/python3