Wiki
Clone wikibase-environment / Venv+pip
Venv + pip
Usage looks like
Create a new virtual environment called venv
inside the current folder:
$ python -m venv venv
Activate it by sourcing the activate script inside the virtual environment:
source venv/bin/activate (venv)$
With the virtual environment activated, install packages local to the project with:
(venv)$ python -m pip install <package-name>
For testing, consistent coding style, understandable code and protection from the most common security vulnerabilities, install:
(venv)$ python -m pip install pytest-cov isort flake8 bandit safety pre-commit mypy isort black
To deactivate run
(venv)$ deactivate
For reproducibility, you can keep a list of required packages for the project inside a requirements.txt
file. You can manually create the file and add packages or use the pip freeze command to generate it:
(venv)$ python -m pip freeze > requirements.txt
And you'll have to manually separate development (pytest, black, isort, ...) and production (Flask, Django, FastAPI, ..) dependencies using a separate requirements-dev.txt
file.
Updated