← All recipes
Moderne licensed

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

Recipe IDorg.openrewrite.github.SetupPythonToUvArtifactorg.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@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.

Single recipeMSAL

Add to your build

Get a download tokenThis recipe is Moderne licensed, so the token must belong to a Moderne customer. It replaces YOUR_DOWNLOAD_TOKEN below.

~/.gradle/gradle.properties

codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN

build.gradle.kts

plugins {
    id("org.openrewrite.rewrite") version("latest.release")
}

rewrite {
    activeRecipe("org.openrewrite.github.SetupPythonToUv")
}

repositories {
    mavenCentral()
    maven {
        url = uri("https://artifacts.codegenomeproject.org/maven")
        credentials {
            username = providers.gradleProperty("codeGenomeUsername").get()
            password = providers.gradleProperty("codeGenomeToken").get()
        }
    }
}

dependencies {
    rewrite("org.openrewrite.recipe:rewrite-github-actions:3.32.0")
}

Then run

./gradlew rewriteRun

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:RELEASE

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.txt → uv sync - pip install . → uv sync - python -m pytest → uv 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