uv plugin

The uv plugin is designed for Python charms that use uv as the build system and are written with the Operator framework.

Keywords

In addition to the common plugin and sources keywords, this plugin provides the following plugin-specific keywords:

uv-extras

Type: list of strings

Extra dependencies to build with. Each element of the list is passed exactly as --extra EXTRA.

uv-groups

Type: list of strings

Extra dependency groups to build with. Each element of the list is passed exactly as --group GROUP.

python-keep-bins

Type: boolean Default: False

Whether to keep Python scripts in the virtual environment’s bin directory.

How it works

During the build step, the plugin performs the following actions:

  1. It creates a virtual environment in the ${CRAFT_PART_INSTALL}/venv directory.

  2. It runs uv sync to install the packages referenced in the pyproject.toml and uv.lock files, along with any optional groups or extras specified.

  3. It copies any existing src and lib directories from your charm project into the final charm.

Example

The following charmcraft.yaml file can be used with a uv project to craft a charm with Ubuntu 24.04 as its base:

name: my-charm
type: charm
title: My uv charm
summary: An operator charm using uv.
description: |
  An operator charm that uses uv for its project.
base: [email protected]
platforms:
  amd64:
parts:
  my-charm:
    source: .
    plugin: uv