Virtual Environment¶
This project environment is build using Anaconda, while the package management is done using the Python tool Poetry. The only requirement is to have anaconda installed and to be able to run commands using the conda
methods in a terminal. More informations on enabling the conda
method in Visual Studio Code here.
Conda¶
The conda environment is defined by the environment.yml file. This file contains the bare minimum to build the environment :
- The Python version to use when creating the environment.
- The Poetry version to load when creating the environment.
- Any module/package which couldn't be installed using Poetry.
Poetry¶
The dependencies versions are defined in the pyproject.toml file. This file contains informations on the packages/modules version to use when building the environment.
Environment setup¶
-
Create the virtual environment from the file
environment.yml
:conda env create --file environment.yml --prefix ./.venv
$CONDA_EXE env create --file environment.yml --prefix ./.venv
$CONDA_EXE
Variable referring to the conda executable path. It should be already existing.
conda env create
https://docs.conda.io/projects/conda/en/latest/commands/create.html
-
Activate the virtual environment located in
./.venv
: TODO : add line about where to find the environment's nameconda activate ./.venv
Not needed.
-
Build the environment:
In the virtual environment:
poetry install
.venv/bin/poetry install
poetry install
Installing groups
In the dependencies file (pyproject.toml), dependencies are organized into groups, main (nameless), dev and docs.
poetry install
will install all dependencies, regardless of their group.poetry install --only docs
will only install the 'docs' group.poetry install --without dev,docs
will install without the docs and dev groups. -
Run the python script
hello_world.py
:In the virtual environment:
python hello_world.py
.venv/bin/python hello_world.py
-
Updating the environment:
In the virtual environment:
poetry update
.venv/bin/poetry update
poetry update
-
Deactivate the environment:
In the virtual environment:
conda deactivate
Not needed.