Poetry is a dependency management and packaging tool for Python that aims to simplify and enhance the development process. It offers features for managing dependencies, virtual environments, and building and publishing Python packages.
Poetry manages virtual environments for your projects to ensure clean and isolated development environments.
poetry install
poetry shell
Alternatively you can source the environment settings in the current shell
source $(poetry env info --path)/bin/activate
for powershell users this would be
(& ((poetry env info --path) + "\Scripts\activate.ps1")
When using poetry shell
exit
When using the activate
script
deactivate
Poetry uses the pyproject.toml
file to manage dependencies. Add new
dependencies to this file and update existing ones as needed.
poetry add package-name
poetry add --dev package-name
poetry remove package-name
poetry update
Poetry provides a way to run scripts and commands without activating the virtual environment explicitly.
poetry run command-name
poetry run python script.py
Poetry streamlines the process of building and publishing Python packages.
poetry build
poetry publish
Extras allow you to specify additional dependencies based on project requirements.
poetry install -E extras-name
for example
poetry install -E "askar bbs indy"
Development dependencies are useful for tasks like testing, linting, and documentation generation.
poetry install --dev