Logo Kevin's Public Notes

Useful uv commands

Intro#

I like uv. To install go to https://docs.astral.sh/uv/.

Inspired by UV tricks - Bite code! and A year of uv: pros, cons, and should you migrate

What is uvx#

It's an alias for uv run which works like npx. It lets you run commands and binaries in your terminal without having to worry about creating a virtualenv or the install process in general.

Audit Dependencies of Python projects#

# audit uv.lock
uvx uv-secure

# audit requirements.txt / pip
uvx pip-audit -r requirements.txt

# audit poetry.lock
uvx --with poetry-audit-plugin poetry audit

Utilities#

# download
uvx yt-dlp --no-cache <video_link>
# or if you need auth and it's supported on the site
uvx yt-dlp --no-cache --cookies-from-browser <firefox|chrome|safari|edge> <video_link>

# format your code
uvx ruff format

# lint your code
uvx pylint .

# transfer files on LAN
uvx copyparty

# initialize a very robust uv-managed python project in project_name dir
# 	(find more templates at https://github.com/topics/copier-template)
uvx \
	--with copier-template-extensions --with jinja2-time \
	copier copy --trust 'https://github.com/pawamoy/copier-uv.git' project_name