Python package management: A new, promising tool called UV
- Von Torben Windler
- Data Science
Share post:
In our role as a data science and AI consultancy, we are constantly looking for tools that make our work in our customer projects more efficient. A well-known challenge in the Python ecosystem is the package manager pip, especially in large projects with many dependencies. This is exactly where UV from Astral comes into play.
Our situation
Python is the language of choice in our projects. The ecosystem is so mature and you can access libraries in different programming languages to do certain things optimally.
However, a well-known complex task is the
Managing of dependencies and environments.
As things stand at the moment, we mainly use poetry for Python package management, which we like quite a lot, not least because of the simple syntax, but still many manual intervention options.
Nevertheless, the correct Python version has to be installed manually and resolving the dependencies can take a little longer, especially for large projects. So when we heard about UV, we definitely had to try it!
What does UV bring us?
1. Speed!
UV is incredibly fast when resolving and installing dependencies. This is mainly due to efficient caching if the packages have already been installed on the same machine, but also to the fact that UV is written entirely in Rust and therefore benefits from the advantages of this compiled language.
2. Reproducibility!
With multiple developers on a project, different platforms and dev, test and prod environments, it can be quite complex to always create the exact same conditions. This can lead to bugs, which can be very difficult to identify. UV takes over the complete management of dependencies and the development environment, ensuring that the same requirements can be met on every platform.
3. Syntax!
UV has a very similar syntax to Poetry, which we have been using as standard in new projects for around two years. The underlying pyproject.toml and *.lock files are also already known from Poetry. A very understandable and largely familiar syntax can be used here to make a quick change.
4. Integration!
UV integrates seamlessly into existing workflows so that developers do not have to adapt their work. Existing requirements.txt files work directly with UV, and familiar commands such as `pip install` can be easily replaced by UV.
In addition, the Astral team has already created a very good tool called Ruff, which we use as a standard. This gives us an additional level of confidence and a justified hope that UV will also be further developed in a stable manner.
Conclusion
According to the manufacturer Astral, UV brings some promising improvements for Python package management. I have tested UV myself in a toy project and I am already very impressed. The advantages described in terms of performance, seamless integration and independence from Python are definitely no empty promises. There are many more possibilities with UV, for example, the workspaces are very interesting for me, as we have many projects based on independent microservices, which we could then manage uniformly.
We are planning to try out UV in our future projects and check carefully whether the promised benefits can also be experienced in real projects. We are also monitoring further developments and are looking forward to further ideas from Astral!
Torben Windler
Lead AI Engineer