From the course: Create an Open-Source Project in Python

What is Poetry?

- [Instructor] Poetry is both a Python packaging tool and a dependency management tool. In this course though, we are only going to use Poetry as a dependency management tool. The most straightforward way of managing your dependencies in the Python project is to first list all the external libraries and diversion numbers in the requirements doc text file. Then you use pip, which comes with most distribution of Python to install the dependencies listed in the file. This is what we call the bare minimum setup but there's some problems with it. To start with, you'll end up with a lot of dependencies that you have no idea where they come from. For example, with this requirements doc text file you'll end up with all these libraries installed. Reason being that some of the libraries in the requirements doc text file depend on other libraries as well, and they will all get installed. This is to make sure that you have everything you need in this environment for your projects to work, but then you end up with a lot more dependencies than what you're expecting. Now, to make things worse if you're working with multiple projects they won't be installed in isolated environments. In other words, each project requirements doc text and all their dependencies will get mixed up with each other, and at the end of the day you will have no idea which dependencies come from which project because again you can't trace where they're coming from. If you're lucky enough, everything will still work and you won't end up with conflicts. Sometimes it may happens that project requires a specific version of library while other projects requires a different version of it, but since it's not allowed to have two versions of the same library installed in the same environment, a conflict is created. You cannot get both projects working fine at the same time with same environment, and that's why we use Poetry. Poetry provides a solution for all these problems. First, it provides a way of tracking where dependencies comes from. The simple command poetry show --three, shows all your dependencies in a tree diagram showing you exactly what you have in your environment and why they are there. The second thing Poetry provides are isolated environments for each project you create. And since you they don't share the same environment, the risk of conflict is minimized. Finally, many projects support multiple version of Python. If you ship your projects to another person with a different version of Python, Poetry will try to find the appropriate versions of the dependencies automatically and install them to make sure it works for all supported version of Python. Yes, Poetry is that great. So let's start using it.

Contents