Replace actions/setup-python with astral-sh/setup-uv

MSAL

Replace actions/setup-python action with astral-sh/setup-uv action for faster Python environment setup and dependency management.

Benefits of UV:

  • Significantly faster package installation and environment setup
  • Built-in dependency resolution and locking
  • Integrated caching for improved CI performance
  • Drop-in replacement for pip workflows

Transformations applied:

  • actions/setup-python@v5 → astral-sh/setup-uv@v6
  • cache: 'pip' → enable-cache: 'true'
  • pip install -r requirements.txt → uv sync (configurable strategy)
  • python -m <module> → uv run <module>
  • Removes unnecessary pip install --upgrade pip steps

Sync strategies:

  • basic: Basic synchronization (uv sync)
  • locked: Use locked dependencies (uv sync --locked)
  • full: Install all extras and dev dependencies (uv sync --all-extras --dev)

See the UV GitHub integration guide for more details.

org.openrewrite.github.SetupPythonToUv

Optional

The version of the astral-sh/setup-uv action to use. Defaults to v6.

Strategy for the uv sync command replacement.

transformPipCommandsBoolean

Whether to transform pip install commands to uv equivalents:

  • pip install -r requirements.txt → uv sync
  • pip install . → uv sync
  • python -m pytest → uv run pytest

When disabled, only the action itself is replaced. Defaults to true.

enableCacheBoolean

Whether to automatically convert cache: 'pip' to enable-cache: 'true' for UV's built-in caching. When disabled, cache settings are left unchanged. Defaults to true.

mod run . --recipe=org.openrewrite.github.SetupPythonToUv

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.