It a all in one tool that:-
- Manages virtual env for python projects
- Manages dependencies for python projects
- Publish python packages to PyPI
pip install poetryThis will create a pyproject.toml file
poetry initpoetry installpoetry env infoDelete existing virtual env folder and then run the following command followed by the install command, make sure to add the .venv/ folder in .gitignore
poetry config virtualenvs.in-project trueRun the follwing command then you can run any project related command after that
poetry shell
poetry run COMMANDRun this while in the activated shell
exitRun this while in the activated shell
deactivatepoetry env listThis will add the PACKAGE_NAME to the pyproject.toml
poetry add PACKAGE_NAMEThis will remove the PACKAGE_NAME from the pyproject.toml
poetry remove PACKAGE_NAMEpoetry showThis file is automatically created when you run poetry install or poetry add PACKAGE_NAME. It locks the dependencies to specific versions to ensure consistency across different environments.
poetry add [email protected] #Install the latest minor and patch version that matches 4.17.1
poetry add PACKAGE_NAME@^4.17.1 # Install the latest minor and patch version that matches 4.x.x (but not 5.0.0)
poetry add PACKAGE_NAME~4.14.1 # Install the latest patch version that matches 4.17.x (but not 4.18.0).
poetry add "PACKAGE_NAME@*" # Installs the latest minor and patch version, but will also update to the last major version if available when updatedpoetry update| Command | New version (example) | Effect / Meaning | 
|---|---|---|
| poetry version | - | prints current version (just shows current) | 
| poetry version patch | 1.2.4(from1.2.3) | bump patch version — bug fixes only | 
| poetry version minor | 1.3.0(from1.2.3) | bump minor version — backward-compatible feature additions | 
| poetry version major | 2.0.0(from1.2.3) | bump major version — breaking changes | 
| poetry version prepatch | 1.2.4-alpha.0 | create a pre-release | 
| poetry version 3.0.0 | 3.0.0 | explicitly set version |