A couple of months ago I made the switch from poetry to uv. I’m writing the post just to say i love it 💚, and you should use it too! Here’s how it impacts my development expericence and how I use it to quickstart new Python projects.
TLDR; uv simplifies my whole development experience. I use it with my own cookiecutter template – available here:
What is uv?
If you’re reading this, you probably already know uv. But just in case, here’s a quick summary:
uv is a package management tool that allows you manage your Python installations. It’s main selling point is its speed since uv is written in Rust. And fast it is! Nonetheless, it has a lot more features to offer.
Why I switched to uv
I was using poetry, it’s a great tool, don’t get me wrong. Then I discovered uv, was curious and simply gave it a try. Soon I ‘exclusively’ set-up new projects with uv. Later, I even started to migrate my existing projects to uv. Since I was already used to the pyproject.toml file for project configuration, the migration was easy. Along the way I discovered a couple of features that impact my workflow positively:
1. Set-up a machine for Python development
There is no need to install Python manually anymore. On a new machine, I simply run the installation command for uv and I’m good to go.
With another
uv python install
command I can install the latest Python version. That’s it for the set-up process.
In fact, I recommend the same approach to my colleagues. Setting up an existing project on a colleague’s machine has never been easier for me. It’s a simple three step process:
- Install uv
- Clone the repository
- Run
uv sync
Even if my colleague does not have the appropriate Python version installed, uv will take care of that. It will download the correct version and set up a virtual environment for the project.
This way setting up a project is a matter of a couple of minutes.
2. Switching between Python versions
Sometimes I need to switch between Python versions. Previously, I had the manage the Python version manually which lead to a couple of issues. Now, I don’t hesitate and I feel encouraged to test my code with different Python versions.
3. Installing tools
I like some tools like ruff and cookiecutter to be installed system-wide. With uv, I can install them with a single command:
uv tool install ruff
4. Documentation
Sometimes it’s a point overlooked, but I think it’s important to mention: uv has great documentation. It’s easy to find the information you need. Especially, the Integration section was practically a quickstart guide to using uv with Docker and pre-commit. So I was able to easily integrate uv into my projects.
5. Speed
… and of course, uv is fast. Compared to poetry, resolving dependencies is way faster, which reduces friction in my workflow. For example, I am more likely to try out a new package or quickly set up a new environment just to test something out.
How I use it day-to-day
For new projects, I created my own template to quickly set up a new Python project. It is available on GitHub.
The template is centered around uv and includes a suitable project structure and tools for common tasks like testing, linting, and formatting.
If you’d like to use it, follow these three simple steps:
- Install uv (Installation instructions here)
- Install pre-commit and cookiecutter as tools:
uv tool install pre-commit cookiecutte
r - Create a new project with the template:
cookiecutter https://github.com/JakobKlotz/python-template.git
Simple as that! 🚀
So there you have it – uv has transformed my Python workflow with its speed, simplicity, and seamless version management. Give it a try, and I’m confident it will enhance your development experience just as it has mine!