← Back to issue list

Fix uv plugin not caching wheels to LXC host

View original Github issue

Metadata

Project
charmcraft
Number
#2501
Type
pull request
State
open
Author
Copilot
Labels
Created
Updated
Closed

Current evaluation

Adds UV_CACHE_DIR to UV plugin build env to cache source-built wheels on LXC host, with unit and spread tests. 268 days old, 0 reviewers, several CI checks failing (snap-tests, macos-13, Conventional Commits).

Suggested action: needs review

Reason: The PR has been inactive for ~9 months with no maintainer review (0 reviewers), but the underlying issue #2461 remains open and the fix is still relevant. Several CI checks are failing (snap-tests on ubuntu-20.04/22.04, macos-13, Conventional Commits policy) that need a maintainer to triage — the ty type-check failures are explicitly noted as pre-existing and not requiring action. A maintainer needs to review the diff, confirm the CI failures are not PR-introduced, and address the Conventional Commits policy check before this can be merged.

Impact: 45 Quick Win: 29.25 Staleness: 72 Complexity: 35 Confidence: 65

Issue body

## Description Fixes an issue where the UV plugin doesn't cache wheels built from source when `no-binary = true` is set in pyproject.toml. Wheels built during charm packing were not being saved to charmcraft's cache on the LXC host, causing them to be rebuilt on every pack operation. ## Changes Made - **UV Plugin**: Added `UV_CACHE_DIR` environment variable in the UV plugin's build environment to point to the part's cache directory (`charmcraft/parts/plugins/_uv.py`) - **Unit Tests**: Added `test_uv_cache_dir_set` to verify UV_CACHE_DIR is properly configured - **Unit Tests**: Updated `test_get_build_environment` to check for UV_CACHE_DIR presence - **Spread Test**: Created comprehensive end-to-end test at `tests/spread/smoketests/uv-cache/` with two separate UV-based charms to verify caching works correctly - **Linting**: Fixed trailing whitespace and formatting issues in test files - **Test Structure**: Fixed spread test charm structure by moving charm files to required `src/` directory and making them executable ## Testing - ✅ Tested on tag 4.0.1 to confirm issue exists - ✅ Tested on hotfix/3.5 branch (issue exists) - ✅ Tested on hotfix/2.7 branch (N/A - UV plugin doesn't exist) - ✅ Tested on main branch (issue exists) - ✅ All existing UV plugin unit tests pass - ✅ New unit test validates UV_CACHE_DIR configuration - ✅ New spread test validates cache reuse between builds - ✅ Security checks passed (CodeQL found no issues) - ✅ Code review completed - ✅ All linting checks pass - ✅ Spread test structure corrected with proper charm directory layout --- - [ ] I've followed the [contribution guidelines](https://github.com/canonical/charmcraft/blob/main/CONTRIBUTING.md). - [ ] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/). - [ ] I've successfully run `make lint && make test`. - [ ] I've added or updated any relevant documentation. - [ ] I've updated the relevant release notes. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>uv plugin doesn't cache wheels to LXC host</issue_title> > <issue_description>### Bug Description > > When the uv plugin is used with > ```toml > # pyproject.toml > [tool.uv] > no-binary = true > ``` > wheels built from source are not saved to charmcraft's cache on the LXC host > > ### To Reproduce > > ```shell > git clone https://github.com/carlcsaposs-canonical/bug-report-charmcraft-uv-no-cache > cd bug-report-charmcraft-uv-no-cache/ > mkdir ~/foo > CRAFT_SHARED_CACHE=/home/ubuntu/foo charmcraft pack -v > ``` > ```shell > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/ > charmcraft-buildd-base-v7 charmcraft.lock > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/charmcraft-buildd-base-v7/ > BuilddBaseAlias.NOBLE > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/charmcraft-buildd-base-v7/BuilddBaseAlias.NOBLE/ > pip > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ ls ~/foo/charmcraft-buildd-base-v7/BuilddBaseAlias.NOBLE/pip/ > ubuntu@juju-378fe5-stg-carlcsaposs-dev-env-46:~/bug-report-charmcraft-uv-no-cache$ > ``` > > ### Environment > > Ubuntu 24.04 > Using charmcraft with lxc containers > > ### charmcraft.yaml > > ```yaml > type: charm > platforms: > ubuntu@24.04:amd64: > parts: > charm-uv: > plugin: uv > source: . > build-snaps: > - astral-uv > ``` > > ### Relevant log output > > ```shell > N/A > ```</issue_description> > > <agent_instructions>1. Write a test for this that fails when run from the 4.0.1 tag. > 2. Check whether it succeeds on the `hotfix/3.5` branch. > 3. Check whether it succeeds on the `hotfix/2.7` branch. > 4. Check whether it succeeds on the main branch. > > If the test fails on `hotfix/3.5`, target your fix PR at that branch. If it succeeds on both `hotfix/3.5` and `main` but fails on `hotfix/2.7`, write a fix for that branch. > > If it fails on the 4.0.1 tag but succeeds everywhere else, write a comment that this will be resolved in version 4.1.0 and close the issue.</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> - Fixes canonical/charmcraft#2461 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 29.25
Staleness: 72
Complexity: 35
Confidence: 65
needs review Adds UV_CACHE_DIR to UV plugin build env to cache source-built wheels on LXC host, with unit and spread tests. 268 days old, 0 reviewers, several CI checks failing (snap-tests, macos-13, Conventional Commits).
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 20
Confidence: 75
close stale Fixes UV plugin caching bug by setting UV_CACHE_DIR env var. Includes unit and spread tests. Currently inactive for 225 days with failing CI on older Ubuntu/macOS environments.
qwen3.6-35b-a3b-mtp-q6
Staleness: 60
Complexity: 45
Confidence: 85
needs review Fixes UV plugin caching issue by setting UV_CACHE_DIR env var. Includes unit and spread tests. Maintainer feedback applied to fix linting and spread test structure. CI passes except for pre-existing type checker notifications.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 25
Confidence: 70
needs review Adds UV_CACHE_DIR to fix wheel caching in LXC environments. Includes unit and spread tests. Inactive for ~7 months with unrelated type-checking CI noise.
qwen3.6-35b-a3b-mtp-q6
Staleness: 65
Complexity: 25
Confidence: 85
needs review Fixes UV plugin not caching wheels to LXC host when no-binary is enabled by setting UV_CACHE_DIR. Includes unit and spread tests. Linting and test structure issues resolved. Currently awaiting review and merge.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/charmcraft#2461 (confidence 90%)

    PR body explicitly states 'Fixes canonical/charmcraft#2461' and the issue describes the exact bug (UV plugin not caching source-built wheels to LXC host when no-binary=true).

Related issues

Issue Project State Summary Similarity
#2461 uv plugin doesn't cache wheels to LXC host charmcraft open uv plugin with no-binary=true does not persist built wheels to the LXC host shared cache (CRAFT_SHARED_CACHE); only the pip cache dir is mounted, so the uv cache stays container-local.
76%