← Back to issue list

feat(templates): use uv for testing and packing kubernetes and machine charms

View original Github issue

Metadata

Project
charmcraft
Number
#2312
Type
pull request
State
merged
Author
dwilding
Labels
—
Created
Updated
Closed

Current evaluation

PR merged as commit e451f70f: charmcraft init kubernetes/machine profiles now use pyproject.toml deps, tox-uv, the uv plugin for packing, and a uv.lock template; docs updated, requirements-dev.txt page removed.

Resolution: closed resolved

Reason: PR #2312 was approved by three reviewers and merged as commit e451f70f ("feat(templates): use uv for testing and packing kubernetes and machine charms (#2312)"). The change is present in the tree, e.g. docs/reference/files/tox-ini-file.rst documents `uv tool install tox --with tox-uv` and docs/reference/files/uv-lock-file.rst was added.

Evaluated by: mr-cal-bot

No scores available.

Issue body

This PR changes the `kubernetes` and `machine` profiles of `charmcraft init` to use the tox-uv plugin (for testing) and the uv Charmcraft plugin (for packing). [Here's a minimal Kubernetes charm generated from the updated profiles](https://github.com/dwilding/vm/tree/main/demo-api-charm) ### Profile changes - Dependencies are now listed in *pyproject.toml*. I've removed *requirements.txt*. - The environments in *tox.ini* now require uv. The user should install tox with `uv tool install tox --with tox-uv`. - The scope of `tox -e static` now includes *tests/unit/* and *tests/integration/* for the charms. Strictly, this isn't part of switching to uv. - *uv.lock* is provided as part of the profiles. (We went back and forth on this in discussions.) But the file is **not** generated using `uv lock`. The Charm Tech team will periodically refresh the *uv.lock.j2* templates to keep up with major Ops features or dependency issues. - *charmcraft.yaml* now specifies the uv plugin. After discussion (in the comments of this PR), I felt it's best not to have a dedicated dependency group for PYDEPS from charmlibs. - Misc cleanup: I updated some old links to Juju docs and adjusted the formatting of *charmcraft.yaml* to avoid double blank lines. ### Help & doc changes - Modified the help output of `charmcraft init` to: - Explain that *pyproject.toml* specifies dependencies if the profile is `kubernetes` or `machine` - Explain that *requirements.txt* is created for 12-factor profiles only - List *uv.lock* and say that this file is created for `kubernetes` and `machine` - Updated the following docs (links to previews): - [pyproject.toml file](https://canonical-charmcraft--2312.com.readthedocs.build/2312/reference/files/pyproject-toml-file/) - [requirements.txt file](https://canonical-charmcraft--2312.com.readthedocs.build/2312/reference/files/requirements-txt-file/) - [tox.ini file](https://canonical-charmcraft--2312.com.readthedocs.build/2312/reference/files/tox-ini-file/) - [uv.lock file](https://canonical-charmcraft--2312.com.readthedocs.build/2312/reference/files/uv-lock-file/) (new) - Removed [requirements-dev.txt file](https://canonical-charmcraft.readthedocs-hosted.com/stable/reference/files/requirements-dev-txt-file/) because it doesn't seem to be referenced anywhere and I can't find any Charmcraft code that creates/uses this file. I've redirected the page to [requirements.txt file](https://canonical-charmcraft--2312.com.readthedocs.build/2312/reference/files/requirements-txt-file/). --- Follow-up actions: - Expand docs about the uv plugin - see https://github.com/canonical/charmcraft/issues/2238#issuecomment-2900521717 - After the profile changes are released, https://github.com/canonical/operator/issues/1742

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved PR merged as commit e451f70f: charmcraft init kubernetes/machine profiles now use pyproject.toml deps, tox-uv, the uv plugin for packing, and a uv.lock template; docs updated, requirements-dev.txt page removed.
stealth/space-bunny-alpha — closed resolved Merged in #2312 (commit e451f70f): Kubernetes and machine charm templates now use uv/tox-uv, pyproject.toml, and managed uv.lock files, with init help and docs updated.
qwen/qwen3.6-35b-a3b — — Merged. Updated charmcraft init templates for kubernetes and machine profiles to use uv for testing and packing. Replaced requirements.txt with pyproject.toml, added a managed uv.lock template, updated documentation, and bumped the minimum ops version to 3.0.
qwen3.6-35b-a3b-mtp-q6 — — Merged. Updated charmcraft init templates for kubernetes and machine profiles to use uv for dependency management, testing, and packing. Replaced requirements.txt with pyproject.toml, added managed uv.lock templates, updated docs, and set minimum ops to 3.

Update history

No update history recorded yet.

Related work

  • Superseded By: canonical/charmcraft#2754 (confidence 80%)

    Later PR (commit 0be5a5e7) removed the bundled uv.lock template files introduced here and bounded the profile dependencies, superseding part of this PR's design.

  • Likely Fixed By: canonical/charmcraft#2238 (confidence 70%)

    Follow-up doc issue cited in the PR; closed with PR #2413 clarifying the uv plugin migration guide.

Related issues

Issue Project State Summary Similarity
#2365 Add test configuration templates for charmcraft charmcraft closed Test init profiles delivered by merged PR #2401 (commit a7334d49), adding test-machine and test-kubernetes templates for `charmcraft init`; shipped in Charmcraft 4.0.
70%