Using Poetry to manage Python projects

Using Poetry to manage Python projects

Introduction to Poetry

In this video, Serdar Yegulalp introduces Poetry, an all-in-one system for managing projects in Python. He explains how it is different from other command-line utilities and how it can be used to manage dependencies and virtual environments.

What is Poetry?

  • Poetry is an all-in-one system for managing projects in Python.
  • It manages projects for all your Python installations.
  • Unlike other command-line utilities, it does not need to be installed in Python but as a separate application.

Creating a New Project with Poetry

  • To create a new project with Poetry, navigate to the directory where you want your project directory to appear and type poetry new followed by the name of the project.
  • This will create a directory with basic project scaffolding including pi project.toml, readme.rst, tests subdirectory, and a subdirectory with the project's name which holds the actual code.

Managing Dependencies with Poetry

  • By default, a new poetry project doesn't have a virtual environment associated with it. To do that we use poetry's end views command and pass along the path to the exact python executable we want to use.
  • We can add one or more dependencies using the poetry add command.
  • If we want to add a dependency for development purposes only, we can use the same command but include -d flag.
  • A lock file is created when dependencies are installed. This lists all the projects and their specific versions so that projects' dependencies are reproducible.

Conclusion

Poetry is an excellent tool for managing Python projects. It simplifies dependency management and virtual environment creation while providing reproducibility of dependencies across different systems.

Video description

Poetry provides an all-in-one tool for setting up projects, including virtual environments, dependency management, and many other moving parts. Learn the basics in our five-minute introduction. Follow TECH(talk) for the latest tech news and discussion! ------------------------------­---- SUBSCRIBE: http://www.youtube.com/subscription_center?add_user=idgtechtalk FACEBOOK: https://www.facebook.com/idgtechtalk/ TWITTER: https://twitter.com/IDGTechTalk IDG ENTERPRISE WEBSITES Computerworld: https://www.computerworld.com/video/series/8529/tech-talk CIO: https://www.cio.com/video/series/8534/cio-leadership-live CSO: https://www.csoonline.com/video/series/8607/windows-security-tips InfoWorld: https://www.infoworld.com/video/series/8563/do-more-with-r Network World: https://www.networkworld.com/video/series/8559/2-minute-linux-tips