DEV Community

Jacob Hummer
Jacob Hummer

Posted on β€’ Originally published at jcbhmr.me on

uv is awesome

astral-sh/uv is the best Python AiO tool that I've used. Granted, I haven't used a lot; but still. It's pretty good.

  • It manages your Python version so you don't have to wrangle with that at all.
  • It has --dev dependencies unlike plain pip
  • You can still use uv pip <pip_command_args> just as you would normal pip
  • It's ⚑fast⚑
  • It follows PEP standards instead of doing its own thing (looking at you Poetry)
  • A single binary
  • Doesn't require Python to install uv

It does have some downsides:

  • Doesn't bundle a formatter or linter (still have to uv add ruff)
  • Doesn't have a task runner (no uv task <task_name>)
  • Nobody knows about it
  • People confuse it with rye
  • It doesn't have its own build backend (yet)
  • It doesn't bundle a type hint checker

The easiest way to install uv is through one of their installer scripts:

macOS & Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

πŸ“š You can find more installation instructions on the uv website.

Now to create a Python package and publish it to PyPI is as simple as this:

uv init --lib
uv add --dev ruff pyright poethepoet pyinstaller
$EDITOR src/*.py
uv publish

Enter fullscreen mode Exit fullscreen mode

Cool, right? It even manages the Python installation for you automatically.

You can even write standalone Python scripts like this:

#!/usr/bin/env uv run
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# "rich",
# ]
# ///

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])

Enter fullscreen mode Exit fullscreen mode

πŸ“š Read more about running scripts with uv

If you're looking to install a pip-provided CLI tool globally like pip install cmakelang provides cmake-format you can use uv tool install cmakelang. There's also uvx if you want the npx equivalent.

I think uv is cool. It's fast, easy to install, and it gets out of your way. You just write code and use uv run <my_package> or uv run ./entry_point.py to run your project. The virtual environment is not hidden like Poetry; it's right there in .venv if you want to go poking around.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

πŸ‘‹ Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay