← All recipes
Moderne licensed

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

Recipe IDorg.openrewrite.github.SetupPythonToUv
Artifactorg.openrewrite.recipe:rewrite-github-actions

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@v5astral-sh/setup-uv@v6 - cache: 'pip'enable-cache: 'true' - pip install -r requirements.txtuv 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.

Single recipeMSAL

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

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

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-github-actions:3.28.0

Options

NameTypeDescription
uvVersionStringThe version of the astral-sh/setup-uv action to use. Defaults to v6.
e.g. v6
syncStrategyStringStrategy for the uv sync command replacement.
e.g. locked
transformPipCommandsBooleanWhether to transform pip install commands to uv equivalents: - pip install -r requirements.txtuv sync - pip install .uv sync - python -m pytestuv run pytest When disabled, only the action itself is replaced. Defaults to true.
e.g. true
enableCacheBooleanWhether 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.
e.g. true

Data tables

Structured output this recipe can produce.

  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats