UV Migration Guide
This project has been migrated to use uv for Python dependency management and Python 3.13.
What Changed
1. Python Version
- Before: Python 3.10+
- After: Python 3.13+ (enforced via
.python-version)
2. Package Manager
- Before:
pipandvenv - After:
uv(ultra-fast Python package installer and resolver)
3. Build Backend
- Before:
setuptools - After:
hatchling(modern, standards-compliant build backend)
4. Virtual Environments
- All
.venv/directories have been removed uvmanages virtual environments automatically
Prerequisites
Install uv
# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using pip
pip install uv
# Or using pipx
pipx install uv
# On Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
Verify Installation
uv --version
Getting Started
1. Sync Dependencies
The project uses a workspace configuration in the root pyproject.toml. To sync all dependencies:
# From the project root
uv sync
This will:
- Create a virtual environment in
.venv/ - Install all workspace dependencies
- Install all workspace member packages in development mode
2. Build All Packages
make build
# or
./build.sh
The build script now uses uv pip install instead of pip install.
3. Run Tests
make test
# or
./test.sh
The test script now uses uv run pytest to ensure tests run in the uv-managed environment.
4. Clean Build Artifacts
make clean
This now also removes any .venv/ directories.
Workspace Structure
The project uses uv’s workspace feature to manage multiple packages:
mlops-with-mlflow/
├── pyproject.toml # Root workspace configuration
├── .python-version # Python version specification (3.13)
├── uv.lock # Locked dependencies (generated)
└── src/
├── doe-library/ # Workspace member
├── io-library/ # Workspace member
├── feature-library/ # Workspace member
├── metrics-library/ # Workspace member
├── plot-library/ # Workspace member
├── hurricane-landfall/ # Workspace member
└── mlflow-tf/ # Workspace member
Common Commands
Install a New Dependency
# Add to root project
uv add numpy
# Add to specific workspace member
cd src/doe-library
uv add scipy
Run a Script
# Using uv run ensures the correct environment
uv run python script.py
# Or activate the environment
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
python script.py
Update Dependencies
# Update all dependencies
uv sync --upgrade
# Update specific package
uv add numpy@latest
Lock Dependencies
# Create/update uv.lock
uv lock
Benefits of uv
- Speed: 10-100x faster than pip
- Deterministic: Lock file ensures reproducible builds
- Workspace Support: Manage multiple packages in a monorepo
- Modern: Uses latest Python packaging standards
- Simple: Fewer commands, less configuration
Migration Checklist
- Install uv
- Remove all
.venv/directories - Create
.python-versionfile - Create root
pyproject.tomlwith workspace configuration - Update all package
pyproject.tomlfiles to require Python 3.13 - Update build backend from setuptools to hatchling
- Update
build.shto useuv pip install - Update
test.shto useuv run pytest - Update
.gitignoreto include.venv/ - Update Makefile clean target
- Run
uv syncto create lock file - Run
make buildto verify builds work - Run
make testto verify tests work
Troubleshooting
uv not found
# Make sure uv is in your PATH
export PATH="$HOME/.local/bin:$PATH"
Python 3.13 not available
# uv can install Python versions for you
uv python install 3.13
Workspace sync fails
# Try removing the lock file and resyncing
rm uv.lock
uv sync
Package installation fails
# Clear uv cache
uv cache clean
# Try again
uv sync
Further Reading
- uv Documentation
- UV Guide - Complete guide
- UV Quick Reference - Command cheat sheet
- UV Troubleshooting - Problem solving
- pip to UV Migration - For pip users
- Python Packaging User Guide
- PEP 621 - Storing project metadata in pyproject.toml
Support
For issues related to:
- uv: https://github.com/astral-sh/uv/issues
- This project: Open an issue in the project repository