Loading...
Loading...
Guides the agent through Python project management with uv, the fast Rust-based package and project manager. Triggered when users say "create a Python project", "init a Python project with uv", "add a dependency", "manage Python packages", "sync dependencies", "lock dependencies", "run a Python script", "set up pyproject.toml", or mention uv, package management, virtual environments, or Python project initialization.
npx skill4agent add ingpdw/pdw-python-dev-tool package-managing.venvuv init# Create a project in a new directory
uv init my-project
# Initialize in the current directory
uv init
# Create an application project (default, no build system)
uv init --app my-app
# Create a library project (includes build system for publishing)
uv init --lib my-lib
# Specify minimum Python version at init time
uv init --python ">=3.12" my-project--appmy-app/
.python-version
pyproject.toml
README.md
main.py--libmy-lib/
.python-version
pyproject.toml
README.md
src/
my_lib/
__init__.py
py.typed--appsrc/pyproject.toml[project]
name = "my-project"
version = "0.1.0"
description = "A short project description"
requires-python = ">=3.12"
readme = "README.md"
license = { text = "MIT" }
dependencies = [
"fastapi>=0.115",
"uvicorn[standard]>=0.34",
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"[dependency-groups][dependency-groups]
dev = [
"pytest>=8.0",
"pytest-asyncio>=0.25",
"ruff>=0.9",
"mypy>=1.14",
]
docs = [
"mkdocs>=1.6",
"mkdocs-material>=9.5",
][tool.uv][tool.uv]
# Override dependency resolution for specific packages
override-dependencies = [
"numpy>=2.0",
]
# Constrain transitive dependency versions
constraint-dependencies = [
"grpcio<1.70",
]
# Default groups to install on uv sync
default-groups = ["dev"]assets/pyproject-template.toml# Add a production dependency
uv add fastapi
# Add with version constraint
uv add "pydantic>=2.0,<3.0"
# Add multiple packages at once
uv add fastapi uvicorn pydantic-settings
# Add a development dependency
uv add --dev pytest ruff mypy
# Add to a named dependency group
uv add --group docs mkdocs mkdocs-material
# Add with extras
uv add "uvicorn[standard]"
# Add a git dependency
uv add "my-package @ git+https://github.com/org/repo.git@main"
# Add a local path dependency (editable)
uv add --editable "../shared-lib"# Remove a production dependency
uv remove httpx
# Remove a dev dependency
uv remove --dev mypy
# Remove from a named group
uv remove --group docs mkdocs| Specifier | Meaning |
|---|---|
| Version 1.0 or higher |
| At least 1.0, below 2.0 |
| Compatible release (>=1.4, <2.0) |
| Any patch of 1.4 |
| Environment marker |
uv.lock# Generate or update the lock file
uv lock
# Update a single package in the lock file
uv lock --upgrade-package fastapi
# Upgrade all packages to latest compatible versions
uv lock --upgradeuv lockpyproject.tomluv syncuv adduv removepyproject.tomluv.lockuv.lockuv syncuv.lock# Sync all dependencies (creates .venv if missing)
uv sync
# Sync without updating the lock file (CI-friendly, fails if lock is stale)
uv sync --frozen
# Sync without dev dependencies (production builds)
uv sync --no-dev
# Sync including a specific extra group
uv sync --group docs
# Sync all groups
uv sync --all-groups
# Reinstall all packages from scratch
uv sync --reinstalluv sync --frozenuv run# Run a Python script
uv run python main.py
# Run pytest
uv run pytest tests/ -v
# Run a FastAPI dev server
uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Run FastAPI CLI dev server
uv run fastapi dev app/main.py
# Run ruff linter
uv run ruff check .
# Run mypy type checker
uv run mypy src/
# Run an arbitrary module
uv run python -m my_moduleuv run.venvuv runuv syncuv add# Create a venv with the default Python
uv venv
# Create a venv with a specific Python version
uv venv --python 3.12
# Create a venv at a custom path
uv venv /path/to/venv
# Activate manually (rarely needed with uv run)
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows.venv/bin/python.venv\Scripts\python.exe# Install a specific Python version
uv python install 3.12
# Install multiple versions
uv python install 3.11 3.12 3.13
# Pin the project to a specific version (writes .python-version)
uv python pin 3.12
# List available Python versions
uv python list
# List installed Python versions
uv python list --only-installed.python-version# /// script
# requires-python = ">=3.12"
# dependencies = [
# "httpx>=0.27",
# "rich>=13.0",
# ]
# ///
import httpx
from rich import print
resp = httpx.get("https://api.example.com/data")
print(resp.json())uv run script.py# Install a tool globally
uv tool install ruff
uv tool install uv-publish
# Run a tool without installing (ephemeral)
uv tool run ruff check .
uv tool run --from "huggingface-hub" huggingface-cli
# Shorthand: uvx (alias for uv tool run)
uvx ruff check .
uvx black .
# List installed tools
uv tool list
# Upgrade a tool
uv tool upgrade ruff
# Uninstall a tool
uv tool uninstall ruffuv tool runuvxuv tool install[tool.uv.workspace]
members = [
"packages/*",
"services/*",
]monorepo/
pyproject.toml # Root workspace config
uv.lock # Single shared lock file
packages/
shared-models/
pyproject.toml
src/shared_models/
shared-utils/
pyproject.toml
src/shared_utils/
services/
api-service/
pyproject.toml
src/api_service/
worker-service/
pyproject.toml
src/worker_service/# In services/api-service/pyproject.toml
[project]
dependencies = [
"shared-models",
"shared-utils",
]
[tool.uv.sources]
shared-models = { workspace = true }
shared-utils = { workspace = true }# Sync a specific member
uv sync --package api-service
# Run tests for a specific member
uv run --package api-service pytestuv init --app my-api
cd my-api
uv add fastapi "uvicorn[standard]" pydantic-settings
uv add --dev pytest pytest-asyncio ruff mypy
uv run fastapi dev main.pyuv add "sqlalchemy>=2.0,<3.0"
uv lock
uv syncuv sync --frozen --no-dev
uv run pytest --tb=short
uv run ruff check .
uv run mypy src/# Upgrade everything
uv lock --upgrade
uv sync
# Upgrade a single package
uv lock --upgrade-package fastapi
uv syncfastapiassets/pyproject-template.toml