feat(base): cache uv directory#900
Open
carlcsaposs-canonical wants to merge 3 commits intocanonical:mainfrom
Open
feat(base): cache uv directory#900carlcsaposs-canonical wants to merge 3 commits intocanonical:mainfrom
carlcsaposs-canonical wants to merge 3 commits intocanonical:mainfrom
Conversation
Author
|
The test failures appear to be unrelated to the changes in this PR (I do not have access to retrigger the tests) I built charmcraft using this branch of craft-providers & the uv caching appears to be working ubuntu@dualla:~$ git clone https://github.com/carlcsaposs-canonical/charmcraft.git
Cloning into 'charmcraft'...
remote: Enumerating objects: 21395, done.
remote: Counting objects: 100% (707/707), done.
remote: Compressing objects: 100% (503/503), done.
remote: Total 21395 (delta 501), reused 205 (delta 204), pack-reused 20688 (from 4)
Receiving objects: 100% (21395/21395), 8.35 MiB | 9.48 MiB/s, done.
Resolving deltas: 100% (15338/15338), done.
ubuntu@dualla:~$ cd charmcraft/
ubuntu@dualla:~/charmcraft$ git checkout test-uv-cache
branch 'test-uv-cache' set up to track 'origin/test-uv-cache'.
Switched to a new branch 'test-uv-cache'
ubuntu@dualla:~/charmcraft$ sudo snap install snapcraft --classic
2026-02-09T09:12:57Z INFO Waiting for automatic snapd restart...
snapcraft 8.13.2 from Canonical✓ installed
ubuntu@dualla:~/charmcraft$ snapcraft pack -v
[...]
snapcraft internal error: 1 validation error for Project
version
Value should have at most 32 items after validation, not 33 [type=too_long, input_value='0.0.post3261+g0ddb3bcba.d20260209', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/too_long
Failed to run snapcraft in instance
Full execution log: '/home/ubuntu/.local/state/snapcraft/log/snapcraft-20260209-091339.692530.log'
ubuntu@dualla:~/charmcraft$ nano snap/snapcraft.yaml
ubuntu@dualla:~/charmcraft$ git diff
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 7219dcbe..ab9f5f6b 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -150,7 +150,7 @@ parts:
sed -i 's|#!/bin/sh|#!/snap/charmcraft/current/bin/python3|' $CRAFT_PART_INSTALL/bin/craftctl
version="$(uv pip show charmcraft | grep "Version:" | cut -d' ' -f2)"
- /snap/snapcraft/current/libexec/snapcraft/craftctl set version="${version}"
+ /snap/snapcraft/current/libexec/snapcraft/craftctl set version="0.0" #"${version}"
[ -n "$(echo $version | grep "post")" ] && grade=devel || grade=stable
/snap/snapcraft/current/libexec/snapcraft/craftctl set grade="${grade}"
ubuntu@dualla:~/charmcraft$ snapcraft pack -v
[...]
Packed charmcraft_0.0_arm64.snap
ubuntu@dualla:~/charmcraft$ sudo snap install ./charmcraft_0.0_arm64.snap --dangerous --classic
charmcraft 0.0 installed
ubuntu@dualla:~/charmcraft$ cd
ubuntu@dualla:~$ mkdir foo
ubuntu@dualla:~$ cd foo
ubuntu@dualla:~/foo$ charmcraft init
Charmed operator package file and directory tree initialised.
Now edit the following package files to provide fundamental charm metadata
and other information:
charmcraft.yaml
src/charm.py
src/foo.py
README.md
To manage your charm's dependencies, use uv.
To migrate from the Charm plugin to the uv plugin, see:
https://documentation.ubuntu.com/charmcraft/stable/howto/migrate-plugins/charm-to-uv/
ubuntu@dualla:~/foo$ charmcraft pack
Packed foo_arm64.charm
ubuntu@dualla:~/foo$ ls ~/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7.1/BuilddBaseAlias.NOBLE/
pip uv
ubuntu@dualla:~/foo$ ls ~/snap/charmcraft/common/cache/charmcraft/charmcraft-buildd-base-v7.1/BuilddBaseAlias.NOBLE/uv/
CACHEDIR.TAG archive-v0 interpreter-v4 sdists-v9 wheels-v5 |
carlcsaposs-canonical
added a commit
to carlcsaposs-canonical/craft-parts
that referenced
this pull request
Feb 9, 2026
Companion to canonical/craft-providers#900 When the cache dir is mounted from the LXD host, hardlinking from the global cache (uv's default behavior) is not possible e.g. ``` :: warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. :: If the cache and target directories are on different filesystems, hardlinking may not be supported. :: If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning. ```
carlcsaposs-canonical
added a commit
to carlcsaposs-canonical/craft-parts
that referenced
this pull request
Feb 9, 2026
Companion to canonical/craft-providers#900 When the cache dir is mounted from the LXD host, hardlinking from the global cache (uv's default behavior) is not possible e.g. ``` :: warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. :: If the cache and target directories are on different filesystems, hardlinking may not be supported. :: If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning. ```
Member
|
Lint error is fixed in #910 |
bepri
approved these changes
Feb 13, 2026
Member
|
Also, the test failures involving "tracemalloc" are known flaky tests we haven't been able to figure out, so don't worry about those :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #394
Fixes canonical/charmcraft#2461
uv's cache directory is located in the same parent directory as pip's cache directory
craft-providers/craft_providers/base.py
Lines 831 to 832 in b5b4a45
https://docs.astral.sh/uv/reference/storage/#cache-directory
https://pip.pypa.io/en/stable/topics/caching/#default-paths