Modernizing Python Development: My Switch to UV

Summary of Common UV Commands # Install UV - multiple options available ###################################################### # Windows powershell -ExecutionPolicy ByPass -c "irm <https://astral.sh/uv/install.ps1> | iex" winget install --id=astral-sh.uv -e # Linux/macOS curl -LsSf "https://astral.sh/uv/install.sh" | less brew install uv # Python pipx install uv # alternative is pip uv --version # or 'uv self version' uv --help # --help can be used with all commands uv self update # Update UV itself # Install and Manage Python ###################################################### uv python install # Install latest Python version uv python install 3.10.5 # Install specific Python version uv python install --default # Add python.exe to $HOME\.local\bin\ uv python install --reinstall # Reinstall uv-managed Python versions uv python list # List available Python versions uv python list --managed-python # Only list managed Python versions uv python list --no-managed-python # Only list system Python versions uv python upgrade 3.14 # Install the latest patch version uv python uninstall 3.10.5 # Uninstall version uv python find 3.14 # Show path for a specific python.exe uv run where <exe_name> # Show path(s) of all <exe_name>.exe uv python pin 3.14 # Use a specific version in the _current directory_ # Creates a .python-version file # UV Uninstall uv cache clean # Optional, but recommended rm -r "$(uv python dir)" # Optional, but recommended rm -r "$(uv tool dir)" # Optional, but recommended rm $HOME\.local\bin\uv*.exe # Windows rm ~/.local/bin/uv ~/.local/bin/uvx # Linux/macOS # Run Python ###################################################### uv run python # REPL with default version uv run <script>.py # Default version uv run -p 3.14 <script>.py # Specific version, --python alias uv run python [py_option] # Standard Python cmd options uv run --with <pkg> <script>.py # Include dependency package # Multiple --with allowed # Can use UVX, but take care when trying to run pytest, mypy, etc uvx python@3.14 <script>.py # Specific version # Create Virtual Environment (Venv) ###################################################### uv venv # Use the default Python version uv venv <venv_name> # Specify the Venv name uv venv --python 3.14 # Specify the Python version for the Venv uv venv --seed # Add the PiP module to the Venv # Activate Venus .venv\Scripts\activate # PowerShell source .venv/bin/activate # Linux/macOS deactivate # Add Dependencies - normally into current venv ###################################################### uv add <pkg1,...> # Add one or more dependencies to the project # Version Specifiers allowed, e.g. rich>13.9.1 uv add -r requirements.txt # Add all in the given `requirements.txt` uv remove <pkg1,...> # Remove dependencies from the project # Requires 'pyproject.toml' uv tree # View the dependency tree uv tree --outdated --depth 1 # View latest available versions uv sync # Sync environment from uv.lock uv lock # Create uv.lock (happens automatically anyway) uv sync ---upgrade # Edit pyproject.toml to change package version, then... # 'pyproject.toml' [dependency-groups] uv add --dev <pkg1,...> # Add to the development group uv add --group test <testpkg> # Add to user named `test` group uv add <azurepkg> --optional azure # Add Optional to 'azure' group # Remove is the same ordering, # e.g. "uv remove --dev tox coverage" # Manage Python packages with a pip-compatible interface ###################################################### uv pip list # List packages installed uv pip install <pkg1 pkg2..> # Install package into an environment uv pip install -p 3.14 <pkg> # Install into specific version # Install packages into the system Python environment (non-virtual) uv pip install --system <pkg> # Allow UV to modify an `EXTERNALLY-MANAGED` Python installation uv pip install --system --break-system-packages <pkg> # Create UV Project Areas ###################################################### uv init # Create in CWD, default proj type = --app uv init <proj_name> # Create a default named project uv init --bare # Only create a pyproject.toml uv init --app # Application project - this is the default uv init --package # Package project uv init --lib # Library project uv version # _Project_ version, as listed in the pyproject.toml # Build Project ###################################################### uv build # Build Lib/Pkg using UV or specified Build-Backend # UV Tools ###################################################### # Run Tools uvx <tool> # UVX is an alias for 'uv tool run' uvx <tool@version> # Specify Tool Version: <tool@version> uvx <tool>@latest # Latest Tool Version uv cache clean # Deletes all entries in the cache # Install Tools uv tool install <tool> # [install | uninstall | upgrade] uv tool install <tool>@latest # Install latest version of <tool> uv tool update-shell # Ensure Tool Exe on path (if not already) # Tool Info uv tool dir # Installed source uv tool dir --bin # Installed executable uv tool list # List Installed Tools Introduction Python development is evolving rapidly, and UV is at the forefront of this transformation. In this post, I wanted to document my experience switching to UV, why and I how I’ve started the move to a modern workflow. ...

July 27, 2025 · Jonathan B

Modernizing Python Development: Linting and Formatting with Ruff

Introduction What are Linters and Formatters Linters Formatters Why You Should Use Them What is Ruff? Getting Started with Ruff Installation steps Basic CLI Usage ruff check --output-format concise .\example.py ruff format .\example.py Configuration Rules Integrating Ruff into your workflow CLI IDE Pre-Commit GitHub Action Tips Conclusion Further Reading Introduction Python development is evolving—today, code quality and consistency are more important than ever. Strict is the new cool. Tools like Black have made opinionated formatting mainstream, and the need for readable, maintainable, and error-free code is greater than ever—especially as projects grow and AI-driven code/tools become more prevalent. ...

July 18, 2025 · Jonathan B