Accelerate Charming with UV

A quick update to folks who get here following a web search:

override-build is not longer needed :tada:

Make sure you specify the Python version correctly, e.g.:

[project]
name = "hexanator"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.8"
dependencies = [ ... ]

Feel free to adjust depending on the oldest supported base:

  • Ubuntu 20.04 Python 3.8.2
  • Ubuntu 22.04 Python 3.10.x
  • Ubuntu 24.04 Python 3.12.x

Some way to provide uv tool at build time is still needed, the easiest is to snap install it: (stolen from @jnsgruk)

parts:
    hexanator:
        plugin: uv
        source: .
        build-snaps:
            - astral-uv
        build-packages:
            - cargo

I’m also adding cargo because larger charms typically use charm libs that in turn use pydantic to validate the relation data, and pydantic-core is written in Rust.

2 Likes