Dependency Management in Python: Poetry
Introduction
Poetry is a dependency management and packaging tool in Python, aiming to improve how you define, install, and manage project dependencies.
- Installation: You can install Poetry through its custom installer script or using package managers. The recommended way is to use their installer script to ensure you get the latest version.
- Creating a New Project: Use
poetry new <project-name>to create a new project with a standard layout. - Adding Dependencies: Add new dependencies directly to your project using
poetry add <package>. Poetry will resolve the dependencies and update thepyproject.tomlandpoetry.lockfiles. - Installing Dependencies: Running
poetry installin your project directory will install all dependencies defined in yourpyproject.tomlfile.
Poetry Example
Setting Up a New Project
To create a new project named example_project with Poetry and manage its dependencies: