Full Blog TOC

Full Blog Table Of Content with Keywords Available HERE

Sunday, August 31, 2025

UV

 


In this post we will review the uv - a new python project manager.


I am not a heavy python user. I generally avoid using python for long-term existing projects as its maintainability is much complex due to its limited variable typing, and due to its single core usage. I usually use python for very short lived projects or for LLMs which get support almost only in python. Over the years I got used to all python pains: 


  • Installation and usage the correct version of python and pip
  • Creation of the python VENV
  • Dependencies management using the requirement.txt which somehow never works


And then, about a year ago, a new tool emerged: uv.

The uv provides a complete solution for the entire python project management. It includes:


  • Python version installation and management
  • Dependencies add and locking
  • New project creation
  • VENV management
  • Running helper tools


The funny thing about uv is that it is written in RUST, which is in my opinion a kind of an insult to python.


Anyways, listed below are some basic uv actions.


Create A New Project

To create a new project run the following commands.


mkdir demo
cd demo
uv init
uv python list
uv python pin 3.12
uv env


In case using PyCharm, configure it to use uv:

(make sure you have latest version of PyCharm)


PyCharm Settings --> Python --> Interpreter --> select the existing from the .venv


Dependencies

Adding dependecies is simple, for example, add flask.

uv add flask
uv lock

Notice the uv.lock is automatically updated upon any additional add of dependency.

Unit Test and Converage

To run unit test and converage, add the dependencies as DEV dependencies, and then run the related tests.

uv add --dev pytest coverage
uv run -m coverage run -m pytest
uv run -m coverage report



Example of tests are below.



main.py

def add(a, b):
return a + b

test_main.py

from main import add

def test_add():
assert add(2, 3) == 5




No comments:

Post a Comment