3 min read

Last week, Poetry, a dependency management and packaging tool for Python released their version 1 beta 1. Before venturing into details of this Poetry release, let’s have a brief overview about Python, its issues with dependency management, pipenv and Poetry in general.

There’s no doubt that Python is loved by many developers. It is considered as one of the top-rated programming languages with benefits like extensive support library, less-complex syntax, high productivity, excellent integration feature, and many more. Though it has been rated as one of the fastest growing programming languages in 2019, there are some problems with Python, which if rectified, can make it more powerful and accessible to users.

Python’s poor dependency management is one such issue. Dependency management helps in managing all the libraries required to make an application work. It becomes extremely necessary when working in a complex project or in a multi-environment. An ideal dependency management tool assists in tracking, updating libraries easier and faster, as well as to solve package dependency issues. Python’s dependency management requires users to make a virtual environment to have separate dependencies, manual addition of version number in every file, inability to parallelize dependency installation and more. 

To combat these issues, Python now has two maturing dependency management tools called Pipenv and Poetry. Each of these tools simplify the process of creating a virtual environment and sorting dependencies. 

The PyPA-endorsed Pipenv automatically creates and manages a virtualenv for user projects. It also adds/removes packages from the Pipfile as a user installs/uninstalls packages. Its main features include automatically generating a Pipfile and a Pipfile.lock, if one doesn’t exist, creating a virtualenv, adding packages to a Pipfile when installed to name a few.

On the other hand, Poetry dependency management tool uses only one pyproject.toml file to manage all the dependencies. Poetry allows users to declare the libraries that their project depends on and Poetry will automatically install/update them for the user. It allows projects to be directly published to PyPI, easy tracking of the state of dependencies, and more. 

New features in Poetry v1 beta 1

The major highlight in Poetry v1 beta 1 is the new added support for url dependencies in the pull request checklist. This new feature is a significant one for Python users, as it can be added to a current project via the add command or by modifying the pyproject.toml file directly. 

Other features in Poetry v1 beta 1

  • Support for publishing to PyPI using API tokens
  • Licenses can be identified by their full name
  • Settings can be specified with environment variables
  • Settings no longer need to be prefixed by settings, when using the config command. 

Users, in general, are quite happy with the Poetry dependency management tool for Python, as can be seen in the user reactions below from Hacker News. 

A comment on Hacker News reads, “I like how transparent poetry is about what’s happening when you run it, and how well presented that information is. I’ve come to loathe pipenv’s progress bar. Running it in verbose mode isn’t much better. I can’t be too mad at pipenv, but all in all poetry is a better experience.”

Another user says, “Poetry is very good. I think projects should use it. I hope the rest of the ecosystem can catch up quickly. Tox and pip and and pex need full support for PEP 517/518.”

Another user comments, “When you run poetry, it activates the virtualenv before it runs whatever you wanted.

So `poetry add` (it’s version of pip install) doesn’t require you to have the virtualenv active. It will activate it, run the install, and update your dependency specifications in pyproject.toml. 

You can also do `poetry run` and it will activate the virtualenv before it runs whatever shell command comes after. Or you can do `poetry shell` to run a shell inside the virtualenv. I like the seamless integration, personally.”

Read Next

Łukasz Langa at PyLondinium19: “If Python stays synonymous with CPython for too long, we’ll be in big trouble”

PyTorch 1.2 is here with a new TorchScript API, expanded ONNX export, and more

NumPy 1.17.0 is here, officially drops Python 2.7 support pushing forward Python 3 adoption

A born storyteller turned writer!