feat(templates): use uv for testing and packing kubernetes and machine charms
Metadata
Current evaluation
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.
Suggested action: —
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 |
|---|---|---|---|---|
| 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Updated charmcraft init templates for kubernetes and machine profiles to use uv for testing and packing. Replaced requirements.txt with pyproject.toml, added managed uv.lock.j2 templates, updated docs, and set minimum ops version to 3.0. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2754 feat(profiles): bound dependencies, remove uv.lock files, improve init output | charmcraft | merged | Merged after reviewer approval. Bounded dependencies for kubernetes and machine profiles, removed uv.lock from templates, improved charmcraft init output to match requested profiles, and updated documentation. Fixes #2749. | |
| #2749 Remove uv.lock from `kubernetes` and `machine` profiles | charmcraft | closed | Merged changes to remove uv.lock from kubernetes and machine profiles during charm initialization. Updated init output to guide developers in running uv lock manually. | |
| #2295 feat(templates)!: replace simple profile by kubernetes | charmcraft | merged | Merged breaking changes replacing the simple profile with kubernetes as the default in charmcraft init. The simple profile was removed as kubernetes now covers its use case, and the charm was moved to the Ops repository. Docs updated. | |
| #1867 experimental: switch to uv | charmcraft | closed | Merged to reconfigure charmcraft as a uv project, updating freeze-requirements.sh and enabling uv add for dependency management. |