Old way was to use requirements.txt
but its no long recommended.
New way is to use a dependencies manager
Link: https://python-poetry.org/
Installation: https://python-poetry.org/docs/#installing-with-pipx
Installation using Pipx
- pipx is used to install global cli tools with isolating then in virtual environments.
sudo pip install pipx
pipx install poetry
# upgrade and uninstall is also supported
Init a new project
poetry init
Add Dependencies
poetry add pytest
Add Dependencies with version
poetry add requests@2.12.1
[Default] Add Dependencies with latest version un-till major change
poetry add requests^2.12.1
This will try to install more newer version but not
3.x.x
Add Dependencies upto latest minor version
poetry add requests~2.12.1
This will install
2.12.5
Show all the dependencies
poetry show
# poetry show requests
Remove dependencies
poetry remove pytest
Install Dependencies for new project
poetry install
poetry
can create virtual environment for running the application
Spawn a new shell
poetry shell
poetry version patch
# `x.y.z` this will bump z
poetry version minor
# `x.y.z` this will bump y
poetry version major
# `x.y.z` this will bump x
poetry package
# need pypy credentials